blob: 390ee1969d096f4109a6e127b9c0cc1714ac285c [file] [log] [blame]
Yury Selivanov7c7605f2018-09-11 09:54:40 -07001.. currentmodule:: asyncio
2
3
4.. _asyncio-platform-support:
5
6
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -04007================
8Platform Support
9================
Yury Selivanov7c7605f2018-09-11 09:54:40 -070010
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040011The :mod:`asyncio` module is designed to be portable,
Carol Willinga3c8ba72018-09-13 16:14:41 -070012but some platforms have subtle differences and limitations
13due to the platforms' underlying architecture and capabilities.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070014
15
16All Platforms
17=============
18
19* :meth:`loop.add_reader` and :meth:`loop.add_writer`
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040020 cannot be used to monitor file I/O.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070021
22
23Windows
24=======
25
Kyle Stanleyf9000642019-10-10 19:18:46 -040026**Source code:** :source:`Lib/asyncio/proactor_events.py`,
27:source:`Lib/asyncio/windows_events.py`,
28:source:`Lib/asyncio/windows_utils.py`
29
30--------------------------------------
31
Victor Stinner6ea29c52018-09-25 08:27:08 -070032.. versionchanged:: 3.8
33
34 On Windows, :class:`ProactorEventLoop` is now the default event loop.
35
Yury Selivanov7c7605f2018-09-11 09:54:40 -070036All event loops on Windows do not support the following methods:
37
38* :meth:`loop.create_unix_connection` and
39 :meth:`loop.create_unix_server` are not supported.
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040040 The :data:`socket.AF_UNIX` socket family is specific to Unix.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070041
42* :meth:`loop.add_signal_handler` and
43 :meth:`loop.remove_signal_handler` are not supported.
44
45:class:`SelectorEventLoop` has the following limitations:
46
47* :class:`~selectors.SelectSelector` is used to wait on socket events:
48 it supports sockets and is limited to 512 sockets.
49
50* :meth:`loop.add_reader` and :meth:`loop.add_writer` only accept
51 socket handles (e.g. pipe file descriptors are not supported).
52
53* Pipes are not supported, so the :meth:`loop.connect_read_pipe`
54 and :meth:`loop.connect_write_pipe` methods are not implemented.
55
56* :ref:`Subprocesses <asyncio-subprocess>` are not supported, i.e.
57 :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell`
58 methods are not implemented.
59
60:class:`ProactorEventLoop` has the following limitations:
61
Yury Selivanov7c7605f2018-09-11 09:54:40 -070062* The :meth:`loop.add_reader` and :meth:`loop.add_writer`
63 methods are not supported.
64
65The resolution of the monotonic clock on Windows is usually around 15.6
66msec. The best resolution is 0.5 msec. The resolution depends on the
67hardware (availability of `HPET
68<https://en.wikipedia.org/wiki/High_Precision_Event_Timer>`_) and on the
69Windows configuration.
70
71
72.. _asyncio-windows-subprocess:
73
74Subprocess Support on Windows
75-----------------------------
76
Victor Stinner6ea29c52018-09-25 08:27:08 -070077On Windows, the default event loop :class:`ProactorEventLoop` supports
78subprocesses, whereas :class:`SelectorEventLoop` does not.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070079
80The :meth:`policy.set_child_watcher()
81<AbstractEventLoopPolicy.set_child_watcher>` function is also
82not supported, as :class:`ProactorEventLoop` has a different mechanism
83to watch child processes.
84
85
86macOS
87=====
88
89Modern macOS versions are fully supported.
90
91.. rubric:: macOS <= 10.8
92
93On macOS 10.6, 10.7 and 10.8, the default event loop
94uses :class:`selectors.KqueueSelector`, which does not support
95character devices on these versions. The :class:`SelectorEventLoop`
96can be manually configured to use :class:`~selectors.SelectSelector`
97or :class:`~selectors.PollSelector` to support character devices on
98these older versions of macOS. Example::
99
100 import asyncio
101 import selectors
102
103 selector = selectors.SelectSelector()
104 loop = asyncio.SelectorEventLoop(selector)
105 asyncio.set_event_loop(loop)