Platform Support¶
Theasyncio module is designed to be portable,but some platforms have subtle differences and limitationsdue to the platforms’ underlying architecture and capabilities.
All Platforms¶
loop.add_reader()andloop.add_writer()cannot be used to monitor file I/O.
Windows¶
Source code:Lib/asyncio/proactor_events.py,Lib/asyncio/windows_events.py,Lib/asyncio/windows_utils.py
Changed in version 3.8:On Windows,ProactorEventLoop is now the default event loop.
All event loops on Windows do not support the following methods:
loop.create_unix_connection()andloop.create_unix_server()are not supported.Thesocket.AF_UNIXsocket family is specific to Unix.loop.add_signal_handler()andloop.remove_signal_handler()are not supported.
SelectorEventLoop has the following limitations:
SelectSelectoris used to wait on socket events:it supports sockets and is limited to 512 sockets.loop.add_reader()andloop.add_writer()only acceptsocket handles (e.g. pipe file descriptors are not supported).Pipes are not supported, so the
loop.connect_read_pipe()andloop.connect_write_pipe()methods are not implemented.Subprocesses are not supported, i.e.
loop.subprocess_exec()andloop.subprocess_shell()methods are not implemented.
ProactorEventLoop has the following limitations:
The
loop.add_reader()andloop.add_writer()methods are not supported.
The resolution of the monotonic clock on Windows is usually around 15.6milliseconds. The best resolution is 0.5 milliseconds. The resolution depends on thehardware (availability ofHPET) and on theWindows configuration.
Subprocess Support on Windows¶
On Windows, the default event loopProactorEventLoop supportssubprocesses, whereasSelectorEventLoop does not.
macOS¶
Modern macOS versions are fully supported.
macOS <= 10.8
On macOS 10.6, 10.7 and 10.8, the default event loopusesselectors.KqueueSelector, which does not supportcharacter devices on these versions. TheSelectorEventLoopcan be manually configured to useSelectSelectororPollSelector to support character devices onthese older versions of macOS. Example:
importasyncioimportselectorsselector=selectors.SelectSelector()loop=asyncio.SelectorEventLoop(selector)asyncio.set_event_loop(loop)