Concurrent Execution并发执行¶
The modules described in this chapter provide support for concurrent execution of code. 本章描述的模块支持代码的并发执行。The appropriate choice of tool will depend on the task to be executed (CPU bound vs IO bound) and preferred style of development (event driven cooperative multitasking vs preemptive multitasking). 工具的适当选择将取决于要执行的任务(CPU绑定vs IO绑定)和首选的开发风格(事件驱动协同多任务vs抢占式多任务)。Here’s an overview:这里是一个概述:
threading
—Thread-based parallelism基于线程的并行性multiprocessing
—Process-based parallelism基于进程的并行性Introduction介绍Reference参考Process
and exceptions以及例外情况Pipes and Queues管道和队列Miscellaneous混杂的Connection ObjectsConnection
对象Synchronization primitives同步原语Shared共享的ctypes
Objectsctypes
对象Managers经理Proxy
Objects对象Process Pools进程池Listeners and Clients监听器和客户端Authentication keys身份验证密钥Logging登录中Themultiprocessing.dummy
modulemultiprocessing.dummy
模块
Programming guidelines方案编制准则Examples示例
multiprocessing.shared_memory
—Provides shared memory for direct access across processes为跨进程的直接访问提供共享内存Theconcurrent
packageconcurrent
包concurrent.futures
—Launching parallel tasks启动并行任务subprocess
—Subprocess management子流程管理sched
—Event scheduler事件调度程序queue
—A synchronized queue class同步队列类contextvars
—Context Variables上下文变量
The following are support modules for some of the above services:以下是上述某些服务的支持模块: