summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/library%2Fasyncio.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/python~3.12/library%2Fasyncio.html')
-rw-r--r--devdocs/python~3.12/library%2Fasyncio.html24
1 files changed, 24 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Fasyncio.html b/devdocs/python~3.12/library%2Fasyncio.html
new file mode 100644
index 00000000..f6aa0f06
--- /dev/null
+++ b/devdocs/python~3.12/library%2Fasyncio.html
@@ -0,0 +1,24 @@
+ <span id="asyncio-asynchronous-i-o"></span><h1>asyncio — Asynchronous I/O</h1> <aside class="sidebar"> <p class="sidebar-title">Hello World!</p> <pre data-language="python">import asyncio
+
+async def main():
+ print('Hello ...')
+ await asyncio.sleep(1)
+ print('... World!')
+
+asyncio.run(main())
+</pre> </aside> <p>asyncio is a library to write <strong>concurrent</strong> code using the <strong>async/await</strong> syntax.</p> <p>asyncio is used as a foundation for multiple Python asynchronous frameworks that provide high-performance network and web-servers, database connection libraries, distributed task queues, etc.</p> <p>asyncio is often a perfect fit for IO-bound and high-level <strong>structured</strong> network code.</p> <p>asyncio provides a set of <strong>high-level</strong> APIs to:</p> <ul class="simple"> <li>
+<a class="reference internal" href="asyncio-task#coroutine"><span class="std std-ref">run Python coroutines</span></a> concurrently and have full control over their execution;</li> <li>perform <a class="reference internal" href="asyncio-stream#asyncio-streams"><span class="std std-ref">network IO and IPC</span></a>;</li> <li>control <a class="reference internal" href="asyncio-subprocess#asyncio-subprocess"><span class="std std-ref">subprocesses</span></a>;</li> <li>distribute tasks via <a class="reference internal" href="asyncio-queue#asyncio-queues"><span class="std std-ref">queues</span></a>;</li> <li>
+<a class="reference internal" href="asyncio-sync#asyncio-sync"><span class="std std-ref">synchronize</span></a> concurrent code;</li> </ul> <p>Additionally, there are <strong>low-level</strong> APIs for <em>library and framework developers</em> to:</p> <ul class="simple"> <li>create and manage <a class="reference internal" href="asyncio-eventloop#asyncio-event-loop"><span class="std std-ref">event loops</span></a>, which provide asynchronous APIs for <a class="reference internal" href="asyncio-eventloop#loop-create-server"><span class="std std-ref">networking</span></a>, running <a class="reference internal" href="asyncio-eventloop#loop-subprocess-exec"><span class="std std-ref">subprocesses</span></a>, handling <a class="reference internal" href="asyncio-eventloop#loop-add-signal-handler"><span class="std std-ref">OS signals</span></a>, etc;</li> <li>implement efficient protocols using <a class="reference internal" href="asyncio-protocol#asyncio-transports-protocols"><span class="std std-ref">transports</span></a>;</li> <li>
+<a class="reference internal" href="asyncio-future#asyncio-futures"><span class="std std-ref">bridge</span></a> callback-based libraries and code with async/await syntax.</li> </ul> <p id="asyncio-cli">You can experiment with an <code>asyncio</code> concurrent context in the REPL:</p> <pre data-language="pycon">$ python -m asyncio
+asyncio REPL ...
+Use "await" directly instead of "asyncio.run()".
+Type "help", "copyright", "credits" or "license" for more information.
+&gt;&gt;&gt; import asyncio
+&gt;&gt;&gt; await asyncio.sleep(10, result='hello')
+'hello'
+</pre> <div class="availability docutils container"> <p><a class="reference internal" href="https://docs.python.org/3.12/library/intro.html#availability"><span class="std std-ref">Availability</span></a>: not Emscripten, not WASI.</p> <p>This module does not work or is not available on WebAssembly platforms <code>wasm32-emscripten</code> and <code>wasm32-wasi</code>. See <a class="reference internal" href="https://docs.python.org/3.12/library/intro.html#wasm-availability"><span class="std std-ref">WebAssembly platforms</span></a> for more information.</p> </div> <h4 class="rubric">Reference</h4> <p class="caption" role="heading"><span class="caption-text">High-level APIs</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="asyncio-runner">Runners</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-task">Coroutines and Tasks</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-stream">Streams</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-sync">Synchronization Primitives</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-subprocess">Subprocesses</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-queue">Queues</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-exceptions">Exceptions</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Low-level APIs</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="asyncio-eventloop">Event Loop</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-future">Futures</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-protocol">Transports and Protocols</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-policy">Policies</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-platforms">Platform Support</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-extending">Extending</a></li> </ul> <p class="caption" role="heading"><span class="caption-text">Guides and Tutorials</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="asyncio-api-index">High-level API Index</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-llapi-index">Low-level API Index</a></li> <li class="toctree-l1"><a class="reference internal" href="asyncio-dev">Developing with asyncio</a></li> </ul> <div class="admonition note"> <p class="admonition-title">Note</p> <p>The source code for asyncio can be found in <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/asyncio/">Lib/asyncio/</a>.</p> </div> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
+ <a href="https://docs.python.org/3.12/library/asyncio.html" class="_attribution-link">https://docs.python.org/3.12/library/asyncio.html</a>
+ </p>
+</div>