“Python/docs/3.9/library/concurrency”的版本间差异

来自菜鸟教程
Python/docs/3.9/library/concurrency
跳转至:导航、​搜索
(autoload)
 
(Page commit)
 
第1行: 第1行:
 +
{{DISPLAYTITLE:并发执行 — Python 文档}}
 
<div id="concurrent-execution" class="section">
 
<div id="concurrent-execution" class="section">
  
 
<span id="concurrency"></span>
 
<span id="concurrency"></span>
= Concurrent Execution =
+
= 并发执行 =
  
The modules described in this chapter provide support for concurrent
+
本章中描述的模块为代码的并发执行提供支持。 适当的工具选择将取决于要执行的任务(CPU绑定VS IO绑定)和首选样式的开发风格(事件驱动的协作多任务频率VS抢占式多任务处理)。 这是一个概述:
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). Here's an overview:
 
  
 
<div class="toctree-wrapper compound">
 
<div class="toctree-wrapper compound">
  
* [[../threading|<code>threading</code> --- Thread-based parallelism]]
+
* [[../threading|<code>threading</code> — 基于线程的并行性]]
** [[../threading#thread-local-data|Thread-Local Data]]
+
** [[../threading#thread-local-data|线程本地数据]]
** [[../threading#thread-objects|Thread Objects]]
+
** [[../threading#thread-objects|线程对象]]
** [[../threading#lock-objects|Lock Objects]]
+
** [[../threading#lock-objects|锁定对象]]
** [[../threading#rlock-objects|RLock Objects]]
+
** [[../threading#rlock-objects|RLock 对象]]
** [[../threading#condition-objects|Condition Objects]]
+
** [[../threading#condition-objects|条件对象]]
** [[../threading#semaphore-objects|Semaphore Objects]]
+
** [[../threading#semaphore-objects|信号量对象]]
*** [[../threading#semaphore-example|<code>Semaphore</code> Example]]
+
*** [[../threading#semaphore-example|<code>Semaphore</code> 示例]]
** [[../threading#event-objects|Event Objects]]
+
** [[../threading#event-objects|事件对象]]
** [[../threading#timer-objects|Timer Objects]]
+
** [[../threading#timer-objects|定时器对象]]
** [[../threading#barrier-objects|Barrier Objects]]
+
** [[../threading#barrier-objects|障碍物]]
** [[../threading#using-locks-conditions-and-semaphores-in-the-with-statement|Using locks, conditions, and semaphores in the <code>with</code> statement]]
+
** [[../threading#using-locks-conditions-and-semaphores-in-the-with-statement|<code>with</code> 语句中使用锁、条件和信号量]]
* [[../multiprocessing|<code>multiprocessing</code> --- Process-based parallelism]]
+
* [[../multiprocessing|<code>multiprocessing</code> — 基于进程的并行性]]
** [[../multiprocessing#introduction|Introduction]]
+
** [[../multiprocessing#introduction|介绍]]
*** [[../multiprocessing#the-process-class|The <code>Process</code> class]]
+
*** [[../multiprocessing#the-process-class|<code>Process</code> ]]
*** [[../multiprocessing#contexts-and-start-methods|Contexts and start methods]]
+
*** [[../multiprocessing#contexts-and-start-methods|上下文和启动方法]]
*** [[../multiprocessing#exchanging-objects-between-processes|Exchanging objects between processes]]
+
*** [[../multiprocessing#exchanging-objects-between-processes|在进程之间交换对象]]
*** [[../multiprocessing#synchronization-between-processes|Synchronization between processes]]
+
*** [[../multiprocessing#synchronization-between-processes|进程间同步]]
*** [[../multiprocessing#sharing-state-between-processes|Sharing state between processes]]
+
*** [[../multiprocessing#sharing-state-between-processes|进程间共享状态]]
*** [[../multiprocessing#using-a-pool-of-workers|Using a pool of workers]]
+
*** [[../multiprocessing#using-a-pool-of-workers|使用工人池]]
** [[../multiprocessing#reference|Reference]]
+
** [[../multiprocessing#reference|参考]]
*** [[../multiprocessing#process-and-exceptions|<code>Process</code> and exceptions]]
+
*** [[../multiprocessing#process-and-exceptions|<code>Process</code> 和例外]]
*** [[../multiprocessing#pipes-and-queues|Pipes and Queues]]
+
*** [[../multiprocessing#pipes-and-queues|管道和队列]]
*** [[../multiprocessing#miscellaneous|Miscellaneous]]
+
*** [[../multiprocessing#miscellaneous|各种各样的]]
*** [[../multiprocessing#connection-objects|Connection Objects]]
+
*** [[../multiprocessing#connection-objects|连接对象]]
*** [[../multiprocessing#synchronization-primitives|Synchronization primitives]]
+
*** [[../multiprocessing#synchronization-primitives|同步原语]]
*** [[../multiprocessing#shared-ctypes-objects|Shared <code>ctypes</code> Objects]]
+
*** [[../multiprocessing#shared-ctypes-objects|共享 <code>ctypes</code> 对象]]
**** [[../multiprocessing#module-multiprocessing|The <code>multiprocessing.sharedctypes</code> module]]
+
**** [[../multiprocessing#module-multiprocessing|<code>multiprocessing.sharedctypes</code> 模块]]
*** [[../multiprocessing#managers|Managers]]
+
*** [[../multiprocessing#managers|经理]]
**** [[../multiprocessing#customized-managers|Customized managers]]
+
**** [[../multiprocessing#customized-managers|定制经理]]
**** [[../multiprocessing#using-a-remote-manager|Using a remote manager]]
+
**** [[../multiprocessing#using-a-remote-manager|使用远程管理器]]
*** [[../multiprocessing#proxy-objects|Proxy Objects]]
+
*** [[../multiprocessing#proxy-objects|代理对象]]
**** [[../multiprocessing#cleanup|Cleanup]]
+
**** [[../multiprocessing#cleanup|清理]]
*** [[../multiprocessing#module-multiprocessing|Process Pools]]
+
*** [[../multiprocessing#module-multiprocessing|进程池]]
*** [[../multiprocessing#module-multiprocessing|Listeners and Clients]]
+
*** [[../multiprocessing#module-multiprocessing|听众和客户]]
**** [[../multiprocessing#address-formats|Address Formats]]
+
**** [[../multiprocessing#address-formats|地址格式]]
*** [[../multiprocessing#authentication-keys|Authentication keys]]
+
*** [[../multiprocessing#authentication-keys|认证密钥]]
*** [[../multiprocessing#logging|Logging]]
+
*** [[../multiprocessing#logging|日志记录]]
*** [[../multiprocessing#module-multiprocessing|The <code>multiprocessing.dummy</code> module]]
+
*** [[../multiprocessing#module-multiprocessing|<code>multiprocessing.dummy</code> 模块]]
** [[../multiprocessing#programming-guidelines|Programming guidelines]]
+
** [[../multiprocessing#programming-guidelines|编程指南]]
*** [[../multiprocessing#all-start-methods|All start methods]]
+
*** [[../multiprocessing#all-start-methods|所有启动方法]]
*** [[../multiprocessing#the-spawn-and-forkserver-start-methods|The ''spawn'' and ''forkserver'' start methods]]
+
*** [[../multiprocessing#the-spawn-and-forkserver-start-methods|''spawn'' ''forkserver'' 启动方法]]
** [[../multiprocessing#examples|Examples]]
+
** [[../multiprocessing#examples|例子]]
* [[../multiprocessing.shared_memory|<code>multiprocessing.shared_memory</code> --- Provides shared memory for direct access across processes]]
+
* [[../multiprocessing.shared_memory|<code>multiprocessing.shared_memory</code> — 为跨进程直接访问提供共享内存]]
* [[../concurrent|The <code>concurrent</code> package]]
+
* [[../concurrent|<code>concurrent</code> ]]
* [[../concurrent.futures|<code>concurrent.futures</code> --- Launching parallel tasks]]
+
* [[../concurrent.futures|<code>concurrent.futures</code> — 启动并行任务]]
** [[../concurrent|Executor Objects]]
+
** [[../concurrent|执行器对象]]
** [[../concurrent|ThreadPoolExecutor]]
+
** [[../concurrent|线程池执行器]]
*** [[../concurrent|ThreadPoolExecutor Example]]
+
*** [[../concurrent|线程池执行器示例]]
** [[../concurrent|ProcessPoolExecutor]]
+
** [[../concurrent|进程池执行器]]
*** [[../concurrent|ProcessPoolExecutor Example]]
+
*** [[../concurrent|ProcessPoolExecutor 示例]]
** [[../concurrent|Future Objects]]
+
** [[../concurrent|未来对象]]
** [[../concurrent|Module Functions]]
+
** [[../concurrent|模块功能]]
** [[../concurrent|Exception classes]]
+
** [[../concurrent|异常类]]
* [[../subprocess|<code>subprocess</code> --- Subprocess management]]
+
* [[../subprocess|<code>subprocess</code> — 子进程管理]]
** [[../subprocess#using-the-subprocess-module|Using the <code>subprocess</code> Module]]
+
** [[../subprocess#using-the-subprocess-module|使用 <code>subprocess</code> 模块]]
*** [[../subprocess#frequently-used-arguments|Frequently Used Arguments]]
+
*** [[../subprocess#frequently-used-arguments|常用参数]]
*** [[../subprocess#popen-constructor|Popen Constructor]]
+
*** [[../subprocess#popen-constructor|Popen 构造函数]]
*** [[../subprocess#exceptions|Exceptions]]
+
*** [[../subprocess#exceptions|例外]]
** [[../subprocess#security-considerations|Security Considerations]]
+
** [[../subprocess#security-considerations|安全注意事项]]
** [[../subprocess#popen-objects|Popen Objects]]
+
** [[../subprocess#popen-objects|弹出对象]]
** [[../subprocess#windows-popen-helpers|Windows Popen Helpers]]
+
** [[../subprocess#windows-popen-helpers|Windows Popen 助手]]
*** [[../subprocess#windows-constants|Windows Constants]]
+
*** [[../subprocess#windows-constants|窗口常量]]
** [[../subprocess#older-high-level-api|Older high-level API]]
+
** [[../subprocess#older-high-level-api|较旧的高级 API]]
** [[../subprocess#replacing-older-functions-with-the-subprocess-module|Replacing Older Functions with the <code>subprocess</code> Module]]
+
** [[../subprocess#replacing-older-functions-with-the-subprocess-module|<code>subprocess</code> 模块替换旧功能]]
*** [[../subprocess#replacing-bin-sh-shell-command-substitution|Replacing '''/bin/sh''' shell command substitution]]
+
*** [[../subprocess#replacing-bin-sh-shell-command-substitution|替换 '''/bin/sh''' shell 命令替换]]
*** [[../subprocess#replacing-shell-pipeline|Replacing shell pipeline]]
+
*** [[../subprocess#replacing-shell-pipeline|更换外壳管道]]
*** [[../subprocess#replacing-os-system|Replacing <code>os.system()</code>]]
+
*** [[../subprocess#replacing-os-system|更换 <code>os.system()</code>]]
*** [[../subprocess#replacing-the-os-spawn-family|Replacing the <code>os.spawn</code> family]]
+
*** [[../subprocess#replacing-the-os-spawn-family|更换 <code>os.spawn</code> 系列]]
*** [[../subprocess#replacing-os-popen-os-popen2-os-popen3|Replacing <code>os.popen()</code>, <code>os.popen2()</code>, <code>os.popen3()</code>]]
+
*** [[../subprocess#replacing-os-popen-os-popen2-os-popen3|更换 <code>os.popen()</code><code>os.popen2()</code><code>os.popen3()</code>]]
*** [[../subprocess#replacing-functions-from-the-popen2-module|Replacing functions from the <code>popen2</code> module]]
+
*** [[../subprocess#replacing-functions-from-the-popen2-module|替换 <code>popen2</code> 模块中的函数]]
** [[../subprocess#legacy-shell-invocation-functions|Legacy Shell Invocation Functions]]
+
** [[../subprocess#legacy-shell-invocation-functions|传统 Shell 调用函数]]
** [[../subprocess#notes|Notes]]
+
** [[../subprocess#notes|笔记]]
*** [[../subprocess#converting-an-argument-sequence-to-a-string-on-windows|Converting an argument sequence to a string on Windows]]
+
*** [[../subprocess#converting-an-argument-sequence-to-a-string-on-windows|Windows 上将参数序列转换为字符串]]
* [[../sched|<code>sched</code> --- Event scheduler]]
+
* [[../sched|<code>sched</code> — 事件调度器]]
** [[../sched#scheduler-objects|Scheduler Objects]]
+
** [[../sched#scheduler-objects|调度程序对象]]
* [[../queue|<code>queue</code> --- A synchronized queue class]]
+
* [[../queue|<code>queue</code> — 同步队列类]]
** [[../queue#queue-objects|Queue Objects]]
+
** [[../queue#queue-objects|队列对象]]
** [[../queue#simplequeue-objects|SimpleQueue Objects]]
+
** [[../queue#simplequeue-objects|简单队列对象]]
 +
* [[../contextvars|<code>contextvars</code> — 上下文变量]]
 +
** [[../contextvars#context-variables|上下文变量]]
 +
** [[../contextvars#manual-context-management|手动上下文管理]]
 +
** [[../contextvars#asyncio-support|异步支持]]
  
  
 
</div>
 
</div>
The following are support modules for some of the above services:
+
以下是上述部分服务的支持模块:
  
 
<div class="toctree-wrapper compound">
 
<div class="toctree-wrapper compound">
  
* [[../_thread|<code>_thread</code> --- Low-level threading API]]
+
* [[../_thread|<code>_thread</code> — 低级线程 API]]
  
  
第104行: 第105行:
  
 
</div>
 
</div>
 +
<div class="clearer">
  
[[Category:Python 3.9 中文文档]]
+
 
 +
 
 +
</div>
 +
 
 +
[[Category:Python 3.9 文档]]

2021年10月31日 (日) 04:51的最新版本

并发执行

本章中描述的模块为代码的并发执行提供支持。 适当的工具选择将取决于要执行的任务(CPU绑定VS IO绑定)和首选样式的开发风格(事件驱动的协作多任务频率VS抢占式多任务处理)。 这是一个概述:


以下是上述部分服务的支持模块: