parthtamu/rag-code-assistant
0
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4 <head>5 <meta charset="utf-8" />6 <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="Concurrent Execution" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/concurrency.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="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 s..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_concurrency_f96509bd.png" />15<meta property="og:image:alt" content="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 s..." />16<meta name="description" content="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 s..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20 <title>Concurrent Execution — Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21 22 <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23 <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24 <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25 <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26 <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27 28 <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29 <script src="../_static/doctools.js?v=9bcbadda"></script>30 <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31 <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32 33 <script src="../_static/sidebar.js"></script>34 35 <link rel="search" type="application/opensearchdescription+xml"36 title="Search within Python 3.15.0a6 documentation"37 href="../_static/opensearch.xml"/>38 <link rel="author" title="About these documents" href="../about.html" />39 <link rel="index" title="Index" href="../genindex.html" />40 <link rel="search" title="Search" href="../search.html" />41 <link rel="copyright" title="Copyright" href="../copyright.html" />42 <link rel="next" title="threading — Thread-based parallelism" href="threading.html" />43 <link rel="prev" title="cmd — Support for line-oriented command interpreters" href="cmd.html" />44 45 46 <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47 48 <link rel="canonical" href="https://docs.python.org/3/library/concurrency.html">49 50 51 52 53 <style>54 @media only screen {55 table.full-width-table {56 width: 100%;57 }58 }59 </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61 <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62 <script type="text/javascript" src="../_static/copybutton.js"></script>63 <script type="text/javascript" src="../_static/menu.js"></script>64 <script type="text/javascript" src="../_static/search-focus.js"></script>65 <script type="text/javascript" src="../_static/themetoggle.js"></script> 66 <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67 <meta name="readthedocs-addons-api-version" content="1">68 69 </head>70<body>71<div class="mobile-nav">72 <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73 aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74 <nav class="nav-content" role="navigation">75 <label for="menuToggler" class="toggler__label">76 <span></span>77 </label>78 <span class="nav-items-wrapper">79 <a href="https://www.python.org/" class="nav-logo">80 <img src="../_static/py.svg" alt="Python logo">81 </a>82 <span class="version_switcher_placeholder"></span>83 <form role="search" class="search" action="../search.html" method="get">84 <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85 <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>86 </svg>87 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88 <input type="submit" value="Go">89 </form>90 </span>91 </nav>92 <div class="menu-wrapper">93 <nav class="menu" role="navigation" aria-label="main navigation">94 <div class="language_switcher_placeholder"></div>95 96<label class="theme-selector-label">97 Theme98 <select class="theme-selector" oninput="activateTheme(this.value)">99 <option value="auto" selected>Auto</option>100 <option value="light">Light</option>101 <option value="dark">Dark</option>102 </select>103</label>104 <div>105 <h4>Previous topic</h4>106 <p class="topless"><a href="cmd.html"107 title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">cmd</span></code> — Support for line-oriented command interpreters</a></p>108 </div>109 <div>110 <h4>Next topic</h4>111 <p class="topless"><a href="threading.html"112 title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">threading</span></code> — Thread-based parallelism</a></p>113 </div>114 <script>115 document.addEventListener('DOMContentLoaded', () => {116 const title = document.querySelector('meta[property="og:title"]').content;117 const elements = document.querySelectorAll('.improvepage');118 const pageurl = window.location.href.split('?')[0];119 elements.forEach(element => {120 const url = new URL(element.href.split('?')[0].replace("-nojs", ""));121 url.searchParams.set('pagetitle', title);122 url.searchParams.set('pageurl', pageurl);123 url.searchParams.set('pagesource', "library/concurrency.rst");124 element.href = url.toString();125 });126 });127 </script>128 <div role="note" aria-label="source link">129 <h3>This page</h3>130 <ul class="this-page-menu">131 <li><a href="../bugs.html">Report a bug</a></li>132 <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>133 <li>134 <a href="https://github.com/python/cpython/blob/main/Doc/library/concurrency.rst?plain=1"135 rel="nofollow">Show source136 </a>137 </li>138 139 </ul>140 </div>141 </nav>142 </div>143</div>144 145 146 <div class="related" role="navigation" aria-label="Related">147 <h3>Navigation</h3>148 <ul>149 <li class="right" style="margin-right: 10px">150 <a href="../genindex.html" title="General Index"151 accesskey="I">index</a></li>152 <li class="right" >153 <a href="../py-modindex.html" title="Python Module Index"154 >modules</a> |</li>155 <li class="right" >156 <a href="threading.html" title="threading — Thread-based parallelism"157 accesskey="N">next</a> |</li>158 <li class="right" >159 <a href="cmd.html" title="cmd — Support for line-oriented command interpreters"160 accesskey="P">previous</a> |</li>161 162 <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>163 <li><a href="https://www.python.org/">Python</a> »</li>164 <li class="switchers">165 <div class="language_switcher_placeholder"></div>166 <div class="version_switcher_placeholder"></div>167 </li>168 <li>169 170 </li>171 <li id="cpython-language-and-version">172 <a href="../index.html">3.15.0a6 Documentation</a> »173 </li>174 175 <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">The Python Standard Library</a> »</li>176 <li class="nav-item nav-item-this"><a href="">Concurrent Execution</a></li>177 <li class="right">178 179 180 <div class="inline-search" role="search">181 <form class="inline-search" action="../search.html" method="get">182 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">183 <input type="submit" value="Go">184 </form>185 </div>186 |187 </li>188 <li class="right">189<label class="theme-selector-label">190 Theme191 <select class="theme-selector" oninput="activateTheme(this.value)">192 <option value="auto" selected>Auto</option>193 <option value="light">Light</option>194 <option value="dark">Dark</option>195 </select>196</label> |</li>197 198 </ul>199 </div> 200 201 <div class="document">202 <div class="documentwrapper">203 <div class="bodywrapper">204 <div class="body" role="main">205 206 <section id="concurrent-execution">207<span id="concurrency"></span><h1>Concurrent Execution<a class="headerlink" href="#concurrent-execution" title="Link to this heading">¶</a></h1>208<p>The modules described in this chapter provide support for concurrent209execution of code. The appropriate choice of tool will depend on the210task to be executed (CPU bound vs IO bound) and preferred style of211development (event driven cooperative multitasking vs preemptive212multitasking). Here’s an overview:</p>213<div class="toctree-wrapper compound">214<ul>215<li class="toctree-l1"><a class="reference internal" href="threading.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">threading</span></code> — Thread-based parallelism</a><ul>216<li class="toctree-l2"><a class="reference internal" href="threading.html#introduction">Introduction</a></li>217<li class="toctree-l2"><a class="reference internal" href="threading.html#gil-and-performance-considerations">GIL and performance considerations</a></li>218<li class="toctree-l2"><a class="reference internal" href="threading.html#reference">Reference</a><ul>219<li class="toctree-l3"><a class="reference internal" href="threading.html#thread-local-data">Thread-local data</a></li>220<li class="toctree-l3"><a class="reference internal" href="threading.html#thread-objects">Thread objects</a></li>221<li class="toctree-l3"><a class="reference internal" href="threading.html#lock-objects">Lock objects</a></li>222<li class="toctree-l3"><a class="reference internal" href="threading.html#rlock-objects">RLock objects</a></li>223<li class="toctree-l3"><a class="reference internal" href="threading.html#condition-objects">Condition objects</a></li>224<li class="toctree-l3"><a class="reference internal" href="threading.html#semaphore-objects">Semaphore objects</a></li>225<li class="toctree-l3"><a class="reference internal" href="threading.html#semaphore-example"><code class="xref py py-class docutils literal notranslate"><span class="pre">Semaphore</span></code> example</a></li>226<li class="toctree-l3"><a class="reference internal" href="threading.html#event-objects">Event objects</a></li>227<li class="toctree-l3"><a class="reference internal" href="threading.html#timer-objects">Timer objects</a></li>228<li class="toctree-l3"><a class="reference internal" href="threading.html#barrier-objects">Barrier objects</a></li>229</ul>230</li>231<li class="toctree-l2"><a class="reference internal" href="threading.html#using-locks-conditions-and-semaphores-in-the-with-statement">Using locks, conditions, and semaphores in the <code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code> statement</a></li>232</ul>233</li>234<li class="toctree-l1"><a class="reference internal" href="multiprocessing.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">multiprocessing</span></code> — Process-based parallelism</a><ul>235<li class="toctree-l2"><a class="reference internal" href="multiprocessing.html#introduction">Introduction</a><ul>236<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#the-process-class">The <code class="xref py py-class docutils literal notranslate"><span class="pre">Process</span></code> class</a></li>237<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#contexts-and-start-methods">Contexts and start methods</a></li>238<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#exchanging-objects-between-processes">Exchanging objects between processes</a></li>239<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#synchronization-between-processes">Synchronization between processes</a></li>240<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#sharing-state-between-processes">Sharing state between processes</a></li>241<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#using-a-pool-of-workers">Using a pool of workers</a></li>242</ul>243</li>244<li class="toctree-l2"><a class="reference internal" href="multiprocessing.html#reference">Reference</a><ul>245<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#global-start-method">Global start method</a></li>246<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#process-and-exceptions"><code class="xref py py-class docutils literal notranslate"><span class="pre">Process</span></code> and exceptions</a></li>247<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#pipes-and-queues">Pipes and Queues</a></li>248<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#miscellaneous">Miscellaneous</a></li>249<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#connection-objects">Connection Objects</a></li>250<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#synchronization-primitives">Synchronization primitives</a></li>251<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#shared-ctypes-objects">Shared <code class="xref py py-mod docutils literal notranslate"><span class="pre">ctypes</span></code> Objects</a><ul>252<li class="toctree-l4"><a class="reference internal" href="multiprocessing.html#module-multiprocessing.sharedctypes">The <code class="xref py py-mod docutils literal notranslate"><span class="pre">multiprocessing.sharedctypes</span></code> module</a></li>253</ul>254</li>255<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#managers">Managers</a><ul>256<li class="toctree-l4"><a class="reference internal" href="multiprocessing.html#customized-managers">Customized managers</a></li>257<li class="toctree-l4"><a class="reference internal" href="multiprocessing.html#using-a-remote-manager">Using a remote manager</a></li>258</ul>259</li>260<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#proxy-objects">Proxy Objects</a><ul>261<li class="toctree-l4"><a class="reference internal" href="multiprocessing.html#cleanup">Cleanup</a></li>262</ul>263</li>264<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#module-multiprocessing.pool">Process Pools</a></li>265<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#module-multiprocessing.connection">Listeners and Clients</a><ul>266<li class="toctree-l4"><a class="reference internal" href="multiprocessing.html#address-formats">Address Formats</a></li>267</ul>268</li>269<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#authentication-keys">Authentication keys</a></li>270<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#logging">Logging</a></li>271<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#module-multiprocessing.dummy">The <code class="xref py py-mod docutils literal notranslate"><span class="pre">multiprocessing.dummy</span></code> module</a></li>272</ul>273</li>274<li class="toctree-l2"><a class="reference internal" href="multiprocessing.html#programming-guidelines">Programming guidelines</a><ul>275<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#all-start-methods">All start methods</a></li>276<li class="toctree-l3"><a class="reference internal" href="multiprocessing.html#the-spawn-and-forkserver-start-methods">The <em>spawn</em> and <em>forkserver</em> start methods</a></li>277</ul>278</li>279<li class="toctree-l2"><a class="reference internal" href="multiprocessing.html#examples">Examples</a></li>280</ul>281</li>282<li class="toctree-l1"><a class="reference internal" href="multiprocessing.shared_memory.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">multiprocessing.shared_memory</span></code> — Shared memory for direct access across processes</a></li>283<li class="toctree-l1"><a class="reference internal" href="concurrent.html">The <code class="xref py py-mod docutils literal notranslate"><span class="pre">concurrent</span></code> package</a></li>284<li class="toctree-l1"><a class="reference internal" href="concurrent.futures.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">concurrent.futures</span></code> — Launching parallel tasks</a><ul>285<li class="toctree-l2"><a class="reference internal" href="concurrent.futures.html#executor-objects">Executor Objects</a></li>286<li class="toctree-l2"><a class="reference internal" href="concurrent.futures.html#threadpoolexecutor">ThreadPoolExecutor</a><ul>287<li class="toctree-l3"><a class="reference internal" href="concurrent.futures.html#threadpoolexecutor-example">ThreadPoolExecutor Example</a></li>288</ul>289</li>290<li class="toctree-l2"><a class="reference internal" href="concurrent.futures.html#interpreterpoolexecutor">InterpreterPoolExecutor</a></li>291<li class="toctree-l2"><a class="reference internal" href="concurrent.futures.html#processpoolexecutor">ProcessPoolExecutor</a><ul>292<li class="toctree-l3"><a class="reference internal" href="concurrent.futures.html#processpoolexecutor-example">ProcessPoolExecutor Example</a></li>293</ul>294</li>295<li class="toctree-l2"><a class="reference internal" href="concurrent.futures.html#future-objects">Future Objects</a></li>296<li class="toctree-l2"><a class="reference internal" href="concurrent.futures.html#module-functions">Module Functions</a></li>297<li class="toctree-l2"><a class="reference internal" href="concurrent.futures.html#exception-classes">Exception classes</a></li>298</ul>299</li>300<li class="toctree-l1"><a class="reference internal" href="concurrent.interpreters.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">concurrent.interpreters</span></code> — Multiple interpreters in the same process</a><ul>301<li class="toctree-l2"><a class="reference internal" href="concurrent.interpreters.html#key-details">Key details</a></li>302<li class="toctree-l2"><a class="reference internal" href="concurrent.interpreters.html#introduction">Introduction</a><ul>303<li class="toctree-l3"><a class="reference internal" href="concurrent.interpreters.html#multiple-interpreters-and-isolation">Multiple Interpreters and Isolation</a></li>304<li class="toctree-l3"><a class="reference internal" href="concurrent.interpreters.html#running-in-an-interpreter">Running in an Interpreter</a></li>305<li class="toctree-l3"><a class="reference internal" href="concurrent.interpreters.html#concurrency-and-parallelism">Concurrency and Parallelism</a></li>306<li class="toctree-l3"><a class="reference internal" href="concurrent.interpreters.html#communication-between-interpreters">Communication Between Interpreters</a></li>307<li class="toctree-l3"><a class="reference internal" href="concurrent.interpreters.html#sharing-objects">“Sharing” Objects</a></li>308</ul>309</li>310<li class="toctree-l2"><a class="reference internal" href="concurrent.interpreters.html#reference">Reference</a><ul>311<li class="toctree-l3"><a class="reference internal" href="concurrent.interpreters.html#interpreter-objects">Interpreter objects</a></li>312<li class="toctree-l3"><a class="reference internal" href="concurrent.interpreters.html#exceptions">Exceptions</a></li>313<li class="toctree-l3"><a class="reference internal" href="concurrent.interpreters.html#communicating-between-interpreters">Communicating Between Interpreters</a></li>314</ul>315</li>316<li class="toctree-l2"><a class="reference internal" href="concurrent.interpreters.html#basic-usage">Basic usage</a></li>317</ul>318</li>319<li class="toctree-l1"><a class="reference internal" href="subprocess.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">subprocess</span></code> — Subprocess management</a><ul>320<li class="toctree-l2"><a class="reference internal" href="subprocess.html#using-the-subprocess-module">Using the <code class="xref py py-mod docutils literal notranslate"><span class="pre">subprocess</span></code> Module</a><ul>321<li class="toctree-l3"><a class="reference internal" href="subprocess.html#frequently-used-arguments">Frequently Used Arguments</a></li>322<li class="toctree-l3"><a class="reference internal" href="subprocess.html#popen-constructor">Popen Constructor</a></li>323<li class="toctree-l3"><a class="reference internal" href="subprocess.html#exceptions">Exceptions</a></li>324</ul>325</li>326<li class="toctree-l2"><a class="reference internal" href="subprocess.html#security-considerations">Security Considerations</a></li>327<li class="toctree-l2"><a class="reference internal" href="subprocess.html#popen-objects">Popen Objects</a></li>328<li class="toctree-l2"><a class="reference internal" href="subprocess.html#windows-popen-helpers">Windows Popen Helpers</a><ul>329<li class="toctree-l3"><a class="reference internal" href="subprocess.html#windows-constants">Windows Constants</a></li>330</ul>331</li>332<li class="toctree-l2"><a class="reference internal" href="subprocess.html#older-high-level-api">Older high-level API</a></li>333<li class="toctree-l2"><a class="reference internal" href="subprocess.html#replacing-older-functions-with-the-subprocess-module">Replacing Older Functions with the <code class="xref py py-mod docutils literal notranslate"><span class="pre">subprocess</span></code> Module</a><ul>334<li class="toctree-l3"><a class="reference internal" href="subprocess.html#replacing-bin-sh-shell-command-substitution">Replacing <strong class="program">/bin/sh</strong> shell command substitution</a></li>335<li class="toctree-l3"><a class="reference internal" href="subprocess.html#replacing-shell-pipeline">Replacing shell pipeline</a></li>336<li class="toctree-l3"><a class="reference internal" href="subprocess.html#replacing-os-system">Replacing <code class="xref py py-func docutils literal notranslate"><span class="pre">os.system()</span></code></a></li>337<li class="toctree-l3"><a class="reference internal" href="subprocess.html#replacing-the-os-spawn-family">Replacing the <code class="xref py py-func docutils literal notranslate"><span class="pre">os.spawn</span></code> family</a></li>338<li class="toctree-l3"><a class="reference internal" href="subprocess.html#replacing-os-popen">Replacing <code class="xref py py-func docutils literal notranslate"><span class="pre">os.popen()</span></code></a></li>339</ul>340</li>341<li class="toctree-l2"><a class="reference internal" href="subprocess.html#legacy-shell-invocation-functions">Legacy Shell Invocation Functions</a></li>342<li class="toctree-l2"><a class="reference internal" href="subprocess.html#notes">Notes</a><ul>343<li class="toctree-l3"><a class="reference internal" href="subprocess.html#timeout-behavior">Timeout Behavior</a></li>344<li class="toctree-l3"><a class="reference internal" href="subprocess.html#converting-an-argument-sequence-to-a-string-on-windows">Converting an argument sequence to a string on Windows</a></li>345<li class="toctree-l3"><a class="reference internal" href="subprocess.html#disable-use-of-posix-spawn">Disable use of <code class="docutils literal notranslate"><span class="pre">posix_spawn()</span></code></a></li>346</ul>347</li>348</ul>349</li>350<li class="toctree-l1"><a class="reference internal" href="sched.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sched</span></code> — Event scheduler</a><ul>351<li class="toctree-l2"><a class="reference internal" href="sched.html#scheduler-objects">Scheduler Objects</a></li>352</ul>353</li>354<li class="toctree-l1"><a class="reference internal" href="queue.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">queue</span></code> — A synchronized queue class</a><ul>355<li class="toctree-l2"><a class="reference internal" href="queue.html#queue-objects">Queue Objects</a><ul>356<li class="toctree-l3"><a class="reference internal" href="queue.html#waiting-for-task-completion">Waiting for task completion</a></li>357<li class="toctree-l3"><a class="reference internal" href="queue.html#terminating-queues">Terminating queues</a></li>358</ul>359</li>360<li class="toctree-l2"><a class="reference internal" href="queue.html#simplequeue-objects">SimpleQueue Objects</a></li>361</ul>362</li>363<li class="toctree-l1"><a class="reference internal" href="contextvars.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contextvars</span></code> — Context Variables</a><ul>364<li class="toctree-l2"><a class="reference internal" href="contextvars.html#context-variables">Context Variables</a></li>365<li class="toctree-l2"><a class="reference internal" href="contextvars.html#manual-context-management">Manual Context Management</a></li>366<li class="toctree-l2"><a class="reference internal" href="contextvars.html#asyncio-support">asyncio support</a></li>367</ul>368</li>369</ul>370</div>371<p>The following are support modules for some of the above services:</p>372<div class="toctree-wrapper compound">373<ul>374<li class="toctree-l1"><a class="reference internal" href="_thread.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">_thread</span></code> — Low-level threading API</a></li>375</ul>376</div>377</section>378 379 380 <div class="clearer"></div>381 </div>382 </div>383 </div>384 <div class="sphinxsidebar" role="navigation" aria-label="Main">385 <div class="sphinxsidebarwrapper">386 <div>387 <h4>Previous topic</h4>388 <p class="topless"><a href="cmd.html"389 title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">cmd</span></code> — Support for line-oriented command interpreters</a></p>390 </div>391 <div>392 <h4>Next topic</h4>393 <p class="topless"><a href="threading.html"394 title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">threading</span></code> — Thread-based parallelism</a></p>395 </div>396 <script>397 document.addEventListener('DOMContentLoaded', () => {398 const title = document.querySelector('meta[property="og:title"]').content;399 const elements = document.querySelectorAll('.improvepage');400 const pageurl = window.location.href.split('?')[0];401 elements.forEach(element => {402 const url = new URL(element.href.split('?')[0].replace("-nojs", ""));403 url.searchParams.set('pagetitle', title);404 url.searchParams.set('pageurl', pageurl);405 url.searchParams.set('pagesource', "library/concurrency.rst");406 element.href = url.toString();407 });408 });409 </script>410 <div role="note" aria-label="source link">411 <h3>This page</h3>412 <ul class="this-page-menu">413 <li><a href="../bugs.html">Report a bug</a></li>414 <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>415 <li>416 <a href="https://github.com/python/cpython/blob/main/Doc/library/concurrency.rst?plain=1"417 rel="nofollow">Show source418 </a>419 </li>420 421 </ul>422 </div>423 </div>424<div id="sidebarbutton" title="Collapse sidebar">425<span>«</span>426</div>427 428 </div>429 <div class="clearer"></div>430 </div> 431 <div class="related" role="navigation" aria-label="Related">432 <h3>Navigation</h3>433 <ul>434 <li class="right" style="margin-right: 10px">435 <a href="../genindex.html" title="General Index"436 >index</a></li>437 <li class="right" >438 <a href="../py-modindex.html" title="Python Module Index"439 >modules</a> |</li>440 <li class="right" >441 <a href="threading.html" title="threading — Thread-based parallelism"442 >next</a> |</li>443 <li class="right" >444 <a href="cmd.html" title="cmd — Support for line-oriented command interpreters"445 >previous</a> |</li>446 447 <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>448 <li><a href="https://www.python.org/">Python</a> »</li>449 <li class="switchers">450 <div class="language_switcher_placeholder"></div>451 <div class="version_switcher_placeholder"></div>452 </li>453 <li>454 455 </li>456 <li id="cpython-language-and-version">457 <a href="../index.html">3.15.0a6 Documentation</a> »458 </li>459 460 <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>461 <li class="nav-item nav-item-this"><a href="">Concurrent Execution</a></li>462 <li class="right">463 464 465 <div class="inline-search" role="search">466 <form class="inline-search" action="../search.html" method="get">467 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">468 <input type="submit" value="Go">469 </form>470 </div>471 |472 </li>473 <li class="right">474<label class="theme-selector-label">475 Theme476 <select class="theme-selector" oninput="activateTheme(this.value)">477 <option value="auto" selected>Auto</option>478 <option value="light">Light</option>479 <option value="dark">Dark</option>480 </select>481</label> |</li>482 483 </ul>484 </div> 485 <div class="footer">486 © <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.487 <br>488 This page is licensed under the Python Software Foundation License Version 2.489 <br>490 Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.491 <br>492 493 See <a href="/license.html">History and License</a> for more information.<br>494 495 496 <br>497 498 The Python Software Foundation is a non-profit corporation.499<a href="https://www.python.org/psf/donations/">Please donate.</a>500<br>501 <br>502 Last updated on Mar 10, 2026 (08:58 UTC).503 504 <a href="/bugs.html">Found a bug</a>?505 506 <br>507 508 Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.509 </div>510 511 </body>512</html>