💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](threading.xhtml "threading --- 基于线程的并行") | - [上一页](ctypes.xhtml "ctypes --- Python 的外部函数库") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python 标准库](index.xhtml) » - $('.inline-search').show(0); | # 并发执行 本章中描述的模块支持并发执行代码。 适当的工具选择取决于要执行的任务(CPU密集型或IO密集型)和偏好的开发风格(事件驱动的协作式多任务或抢占式多任务处理)。 这是一个概述: - [`threading` --- 基于线程的并行](threading.xhtml) - [线程本地数据](threading.xhtml#thread-local-data) - [线程对象](threading.xhtml#thread-objects) - [锁对象](threading.xhtml#lock-objects) - [递归锁对象](threading.xhtml#rlock-objects) - [条件对象](threading.xhtml#condition-objects) - [信号量对象](threading.xhtml#semaphore-objects) - [`Semaphore` 例子](threading.xhtml#semaphore-example) - [事件对象](threading.xhtml#event-objects) - [定时器对象](threading.xhtml#timer-objects) - [栅栏对象](threading.xhtml#barrier-objects) - [在 `with` 语句中使用锁、条件和信号量](threading.xhtml#using-locks-conditions-and-semaphores-in-the-with-statement) - [`multiprocessing` --- 基于进程的并行](multiprocessing.xhtml) - [概述](multiprocessing.xhtml#introduction) - [`Process` 类](multiprocessing.xhtml#the-process-class) - [上下文和启动方法](multiprocessing.xhtml#contexts-and-start-methods) - [在进程之间交换对象](multiprocessing.xhtml#exchanging-objects-between-processes) - [进程之间的同步](multiprocessing.xhtml#synchronization-between-processes) - [在进程之间共享状态](multiprocessing.xhtml#sharing-state-between-processes) - [使用工作进程](multiprocessing.xhtml#using-a-pool-of-workers) - [参考](multiprocessing.xhtml#reference) - [`Process` 和异常](multiprocessing.xhtml#process-and-exceptions) - [管道和队列](multiprocessing.xhtml#pipes-and-queues) - [杂项](multiprocessing.xhtml#miscellaneous) - [连接(Connection)对象](multiprocessing.xhtml#connection-objects) - [同步原语](multiprocessing.xhtml#synchronization-primitives) - [Shared `ctypes` Objects](multiprocessing.xhtml#shared-ctypes-objects) - [The `multiprocessing.sharedctypes` module](multiprocessing.xhtml#module-multiprocessing.sharedctypes) - [Managers](multiprocessing.xhtml#managers) - [Customized managers](multiprocessing.xhtml#customized-managers) - [Using a remote manager](multiprocessing.xhtml#using-a-remote-manager) - [代理对象](multiprocessing.xhtml#proxy-objects) - [Cleanup](multiprocessing.xhtml#cleanup) - [进程池](multiprocessing.xhtml#module-multiprocessing.pool) - [Listeners and Clients](multiprocessing.xhtml#module-multiprocessing.connection) - [Address Formats](multiprocessing.xhtml#address-formats) - [Authentication keys](multiprocessing.xhtml#authentication-keys) - [日志](multiprocessing.xhtml#logging) - [The `multiprocessing.dummy` module](multiprocessing.xhtml#module-multiprocessing.dummy) - [Programming guidelines](multiprocessing.xhtml#programming-guidelines) - [All start methods](multiprocessing.xhtml#all-start-methods) - [The *spawn* and *forkserver* start methods](multiprocessing.xhtml#the-spawn-and-forkserver-start-methods) - [示例](multiprocessing.xhtml#examples) - [`concurrent` 包](concurrent.xhtml) - [`concurrent.futures` --- 启动并行任务](concurrent.futures.xhtml) - [执行器对象](concurrent.futures.xhtml#executor-objects) - [ThreadPoolExecutor](concurrent.futures.xhtml#threadpoolexecutor) - [ProcessPoolExecutor例子](concurrent.futures.xhtml#threadpoolexecutor-example) - [ProcessPoolExecutor](concurrent.futures.xhtml#processpoolexecutor) - [ProcessPoolExecutor例子](concurrent.futures.xhtml#processpoolexecutor-example) - [期程对象](concurrent.futures.xhtml#future-objects) - [模块函数](concurrent.futures.xhtml#module-functions) - [Exception类](concurrent.futures.xhtml#exception-classes) - [`subprocess` --- 子进程管理](subprocess.xhtml) - [使用 `subprocess` 模块](subprocess.xhtml#using-the-subprocess-module) - [常用参数](subprocess.xhtml#frequently-used-arguments) - [Popen 构造函数](subprocess.xhtml#popen-constructor) - [异常](subprocess.xhtml#exceptions) - [安全考量](subprocess.xhtml#security-considerations) - [Popen 对象](subprocess.xhtml#popen-objects) - [Windows Popen 助手](subprocess.xhtml#windows-popen-helpers) - [Windows Constants](subprocess.xhtml#windows-constants) - [Older high-level API](subprocess.xhtml#older-high-level-api) - [Replacing Older Functions with the `subprocess` Module](subprocess.xhtml#replacing-older-functions-with-the-subprocess-module) - [Replacing /bin/sh shell backquote](subprocess.xhtml#replacing-bin-sh-shell-backquote) - [Replacing shell pipeline](subprocess.xhtml#replacing-shell-pipeline) - [Replacing `os.system()`](subprocess.xhtml#replacing-os-system) - [Replacing the `os.spawn` family](subprocess.xhtml#replacing-the-os-spawn-family) - [Replacing `os.popen()`, `os.popen2()`, `os.popen3()`](subprocess.xhtml#replacing-os-popen-os-popen2-os-popen3) - [Replacing functions from the `popen2` module](subprocess.xhtml#replacing-functions-from-the-popen2-module) - [Legacy Shell Invocation Functions](subprocess.xhtml#legacy-shell-invocation-functions) - [注释](subprocess.xhtml#notes) - [Converting an argument sequence to a string on Windows](subprocess.xhtml#converting-an-argument-sequence-to-a-string-on-windows) - [`sched` --- 事件调度器](sched.xhtml) - [调度器对象](sched.xhtml#scheduler-objects) - [`queue` --- 一个同步的队列类](queue.xhtml) - [Queue对象](queue.xhtml#queue-objects) - [SimpleQueue 对象](queue.xhtml#simplequeue-objects) 以下是上述某些服务的支持模块: - [`_thread` --- 底层多线程 API](_thread.xhtml) - [`_dummy_thread` --- `_thread` 的替代模块](_dummy_thread.xhtml) - [`dummy_threading` --- 可直接替代 `threading` 模块。](dummy_threading.xhtml) ### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](threading.xhtml "threading --- 基于线程的并行") | - [上一页](ctypes.xhtml "ctypes --- Python 的外部函数库") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python 标准库](index.xhtml) » - $('.inline-search').show(0); | © [版权所有](../copyright.xhtml) 2001-2019, Python Software Foundation. Python 软件基金会是一个非盈利组织。 [请捐助。](https://www.python.org/psf/donations/) 最后更新于 5月 21, 2019. [发现了问题](../bugs.xhtml)? 使用[Sphinx](http://sphinx.pocoo.org/)1.8.4 创建。