Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 1 | .. currentmodule:: asyncio |
| 2 | |
| 3 | |
| 4 | .. _asyncio-platform-support: |
| 5 | |
| 6 | |
Elvis Pranskevichus | 1fa2ec4 | 2018-09-17 19:16:44 -0400 | [diff] [blame^] | 7 | ================ |
| 8 | Platform Support |
| 9 | ================ |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 10 | |
Elvis Pranskevichus | 1fa2ec4 | 2018-09-17 19:16:44 -0400 | [diff] [blame^] | 11 | The :mod:`asyncio` module is designed to be portable, |
Carol Willing | a3c8ba7 | 2018-09-13 16:14:41 -0700 | [diff] [blame] | 12 | but some platforms have subtle differences and limitations |
| 13 | due to the platforms' underlying architecture and capabilities. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 14 | |
| 15 | |
| 16 | All Platforms |
| 17 | ============= |
| 18 | |
| 19 | * :meth:`loop.add_reader` and :meth:`loop.add_writer` |
Elvis Pranskevichus | 1fa2ec4 | 2018-09-17 19:16:44 -0400 | [diff] [blame^] | 20 | cannot be used to monitor file I/O. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 21 | |
| 22 | |
| 23 | Windows |
| 24 | ======= |
| 25 | |
| 26 | All event loops on Windows do not support the following methods: |
| 27 | |
| 28 | * :meth:`loop.create_unix_connection` and |
| 29 | :meth:`loop.create_unix_server` are not supported. |
Elvis Pranskevichus | 1fa2ec4 | 2018-09-17 19:16:44 -0400 | [diff] [blame^] | 30 | The :data:`socket.AF_UNIX` socket family is specific to Unix. |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 31 | |
| 32 | * :meth:`loop.add_signal_handler` and |
| 33 | :meth:`loop.remove_signal_handler` are not supported. |
| 34 | |
| 35 | :class:`SelectorEventLoop` has the following limitations: |
| 36 | |
| 37 | * :class:`~selectors.SelectSelector` is used to wait on socket events: |
| 38 | it supports sockets and is limited to 512 sockets. |
| 39 | |
| 40 | * :meth:`loop.add_reader` and :meth:`loop.add_writer` only accept |
| 41 | socket handles (e.g. pipe file descriptors are not supported). |
| 42 | |
| 43 | * Pipes are not supported, so the :meth:`loop.connect_read_pipe` |
| 44 | and :meth:`loop.connect_write_pipe` methods are not implemented. |
| 45 | |
| 46 | * :ref:`Subprocesses <asyncio-subprocess>` are not supported, i.e. |
| 47 | :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell` |
| 48 | methods are not implemented. |
| 49 | |
| 50 | :class:`ProactorEventLoop` has the following limitations: |
| 51 | |
| 52 | * The :meth:`loop.create_datagram_endpoint` method |
| 53 | is not supported. |
| 54 | |
| 55 | * The :meth:`loop.add_reader` and :meth:`loop.add_writer` |
| 56 | methods are not supported. |
| 57 | |
| 58 | The resolution of the monotonic clock on Windows is usually around 15.6 |
| 59 | msec. The best resolution is 0.5 msec. The resolution depends on the |
| 60 | hardware (availability of `HPET |
| 61 | <https://en.wikipedia.org/wiki/High_Precision_Event_Timer>`_) and on the |
| 62 | Windows configuration. |
| 63 | |
| 64 | |
| 65 | .. _asyncio-windows-subprocess: |
| 66 | |
| 67 | Subprocess Support on Windows |
| 68 | ----------------------------- |
| 69 | |
Carol Willing | a3c8ba7 | 2018-09-13 16:14:41 -0700 | [diff] [blame] | 70 | :class:`SelectorEventLoop` on Windows does not support subproceses. |
| 71 | On Windows, :class:`ProactorEventLoop` should be used instead:: |
Yury Selivanov | 7c7605f | 2018-09-11 09:54:40 -0700 | [diff] [blame] | 72 | |
| 73 | import asyncio |
| 74 | |
| 75 | asyncio.set_event_loop_policy( |
| 76 | asyncio.WindowsProactorEventLoopPolicy()) |
| 77 | |
| 78 | asyncio.run(your_code()) |
| 79 | |
| 80 | |
| 81 | The :meth:`policy.set_child_watcher() |
| 82 | <AbstractEventLoopPolicy.set_child_watcher>` function is also |
| 83 | not supported, as :class:`ProactorEventLoop` has a different mechanism |
| 84 | to watch child processes. |
| 85 | |
| 86 | |
| 87 | macOS |
| 88 | ===== |
| 89 | |
| 90 | Modern macOS versions are fully supported. |
| 91 | |
| 92 | .. rubric:: macOS <= 10.8 |
| 93 | |
| 94 | On macOS 10.6, 10.7 and 10.8, the default event loop |
| 95 | uses :class:`selectors.KqueueSelector`, which does not support |
| 96 | character devices on these versions. The :class:`SelectorEventLoop` |
| 97 | can be manually configured to use :class:`~selectors.SelectSelector` |
| 98 | or :class:`~selectors.PollSelector` to support character devices on |
| 99 | these older versions of macOS. Example:: |
| 100 | |
| 101 | import asyncio |
| 102 | import selectors |
| 103 | |
| 104 | selector = selectors.SelectSelector() |
| 105 | loop = asyncio.SelectorEventLoop(selector) |
| 106 | asyncio.set_event_loop(loop) |