diff options
Diffstat (limited to 'devdocs/python~3.12/library%2Fasyncio-platforms.html')
| -rw-r--r-- | devdocs/python~3.12/library%2Fasyncio-platforms.html | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Fasyncio-platforms.html b/devdocs/python~3.12/library%2Fasyncio-platforms.html new file mode 100644 index 00000000..5705c6ff --- /dev/null +++ b/devdocs/python~3.12/library%2Fasyncio-platforms.html @@ -0,0 +1,18 @@ + <span id="asyncio-platform-support"></span><h1>Platform Support</h1> <p>The <a class="reference internal" href="asyncio#module-asyncio" title="asyncio: Asynchronous I/O."><code>asyncio</code></a> module is designed to be portable, but some platforms have subtle differences and limitations due to the platforms’ underlying architecture and capabilities.</p> <section id="all-platforms"> <h2>All Platforms</h2> <ul class="simple"> <li> +<a class="reference internal" href="asyncio-eventloop#asyncio.loop.add_reader" title="asyncio.loop.add_reader"><code>loop.add_reader()</code></a> and <a class="reference internal" href="asyncio-eventloop#asyncio.loop.add_writer" title="asyncio.loop.add_writer"><code>loop.add_writer()</code></a> cannot be used to monitor file I/O.</li> </ul> </section> <section id="windows"> <h2>Windows</h2> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/asyncio/proactor_events.py">Lib/asyncio/proactor_events.py</a>, <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/asyncio/windows_events.py">Lib/asyncio/windows_events.py</a>, <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/asyncio/windows_utils.py">Lib/asyncio/windows_utils.py</a></p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.8: </span>On Windows, <a class="reference internal" href="asyncio-eventloop#asyncio.ProactorEventLoop" title="asyncio.ProactorEventLoop"><code>ProactorEventLoop</code></a> is now the default event loop.</p> </div> <p>All event loops on Windows do not support the following methods:</p> <ul class="simple"> <li> +<a class="reference internal" href="asyncio-eventloop#asyncio.loop.create_unix_connection" title="asyncio.loop.create_unix_connection"><code>loop.create_unix_connection()</code></a> and <a class="reference internal" href="asyncio-eventloop#asyncio.loop.create_unix_server" title="asyncio.loop.create_unix_server"><code>loop.create_unix_server()</code></a> are not supported. The <a class="reference internal" href="socket#socket.AF_UNIX" title="socket.AF_UNIX"><code>socket.AF_UNIX</code></a> socket family is specific to Unix.</li> <li> +<a class="reference internal" href="asyncio-eventloop#asyncio.loop.add_signal_handler" title="asyncio.loop.add_signal_handler"><code>loop.add_signal_handler()</code></a> and <a class="reference internal" href="asyncio-eventloop#asyncio.loop.remove_signal_handler" title="asyncio.loop.remove_signal_handler"><code>loop.remove_signal_handler()</code></a> are not supported.</li> </ul> <p><a class="reference internal" href="asyncio-eventloop#asyncio.SelectorEventLoop" title="asyncio.SelectorEventLoop"><code>SelectorEventLoop</code></a> has the following limitations:</p> <ul class="simple"> <li> +<a class="reference internal" href="selectors#selectors.SelectSelector" title="selectors.SelectSelector"><code>SelectSelector</code></a> is used to wait on socket events: it supports sockets and is limited to 512 sockets.</li> <li> +<a class="reference internal" href="asyncio-eventloop#asyncio.loop.add_reader" title="asyncio.loop.add_reader"><code>loop.add_reader()</code></a> and <a class="reference internal" href="asyncio-eventloop#asyncio.loop.add_writer" title="asyncio.loop.add_writer"><code>loop.add_writer()</code></a> only accept socket handles (e.g. pipe file descriptors are not supported).</li> <li>Pipes are not supported, so the <a class="reference internal" href="asyncio-eventloop#asyncio.loop.connect_read_pipe" title="asyncio.loop.connect_read_pipe"><code>loop.connect_read_pipe()</code></a> and <a class="reference internal" href="asyncio-eventloop#asyncio.loop.connect_write_pipe" title="asyncio.loop.connect_write_pipe"><code>loop.connect_write_pipe()</code></a> methods are not implemented.</li> <li> +<a class="reference internal" href="asyncio-subprocess#asyncio-subprocess"><span class="std std-ref">Subprocesses</span></a> are not supported, i.e. <a class="reference internal" href="asyncio-eventloop#asyncio.loop.subprocess_exec" title="asyncio.loop.subprocess_exec"><code>loop.subprocess_exec()</code></a> and <a class="reference internal" href="asyncio-eventloop#asyncio.loop.subprocess_shell" title="asyncio.loop.subprocess_shell"><code>loop.subprocess_shell()</code></a> methods are not implemented.</li> </ul> <p><a class="reference internal" href="asyncio-eventloop#asyncio.ProactorEventLoop" title="asyncio.ProactorEventLoop"><code>ProactorEventLoop</code></a> has the following limitations:</p> <ul class="simple"> <li>The <a class="reference internal" href="asyncio-eventloop#asyncio.loop.add_reader" title="asyncio.loop.add_reader"><code>loop.add_reader()</code></a> and <a class="reference internal" href="asyncio-eventloop#asyncio.loop.add_writer" title="asyncio.loop.add_writer"><code>loop.add_writer()</code></a> methods are not supported.</li> </ul> <p>The resolution of the monotonic clock on Windows is usually around 15.6 milliseconds. The best resolution is 0.5 milliseconds. The resolution depends on the hardware (availability of <a class="reference external" href="https://en.wikipedia.org/wiki/High_Precision_Event_Timer">HPET</a>) and on the Windows configuration.</p> <section id="subprocess-support-on-windows"> <span id="asyncio-windows-subprocess"></span><h3>Subprocess Support on Windows</h3> <p>On Windows, the default event loop <a class="reference internal" href="asyncio-eventloop#asyncio.ProactorEventLoop" title="asyncio.ProactorEventLoop"><code>ProactorEventLoop</code></a> supports subprocesses, whereas <a class="reference internal" href="asyncio-eventloop#asyncio.SelectorEventLoop" title="asyncio.SelectorEventLoop"><code>SelectorEventLoop</code></a> does not.</p> <p>The <a class="reference internal" href="asyncio-policy#asyncio.AbstractEventLoopPolicy.set_child_watcher" title="asyncio.AbstractEventLoopPolicy.set_child_watcher"><code>policy.set_child_watcher()</code></a> function is also not supported, as <a class="reference internal" href="asyncio-eventloop#asyncio.ProactorEventLoop" title="asyncio.ProactorEventLoop"><code>ProactorEventLoop</code></a> has a different mechanism to watch child processes.</p> </section> </section> <section id="macos"> <h2>macOS</h2> <p>Modern macOS versions are fully supported.</p> <h4 class="rubric">macOS <= 10.8</h4> <p>On macOS 10.6, 10.7 and 10.8, the default event loop uses <a class="reference internal" href="selectors#selectors.KqueueSelector" title="selectors.KqueueSelector"><code>selectors.KqueueSelector</code></a>, which does not support character devices on these versions. The <a class="reference internal" href="asyncio-eventloop#asyncio.SelectorEventLoop" title="asyncio.SelectorEventLoop"><code>SelectorEventLoop</code></a> can be manually configured to use <a class="reference internal" href="selectors#selectors.SelectSelector" title="selectors.SelectSelector"><code>SelectSelector</code></a> or <a class="reference internal" href="selectors#selectors.PollSelector" title="selectors.PollSelector"><code>PollSelector</code></a> to support character devices on these older versions of macOS. Example:</p> <pre data-language="python">import asyncio +import selectors + +selector = selectors.SelectSelector() +loop = asyncio.SelectorEventLoop(selector) +asyncio.set_event_loop(loop) +</pre> </section> <div class="_attribution"> + <p class="_attribution-p"> + © 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br> + <a href="https://docs.python.org/3.12/library/asyncio-platforms.html" class="_attribution-link">https://docs.python.org/3.12/library/asyncio-platforms.html</a> + </p> +</div> |
