blob: 81d840e23277ea8204279028741f4019cb7361c0 [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
Victor Stinner6ea29c52018-09-25 08:27:08 -070026.. versionchanged:: 3.8
27
28 On Windows, :class:`ProactorEventLoop` is now the default event loop.
29
Yury Selivanov7c7605f2018-09-11 09:54:40 -070030All event loops on Windows do not support the following methods:
31
32* :meth:`loop.create_unix_connection` and
33 :meth:`loop.create_unix_server` are not supported.
Elvis Pranskevichus1fa2ec42018-09-17 19:16:44 -040034 The :data:`socket.AF_UNIX` socket family is specific to Unix.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070035
36* :meth:`loop.add_signal_handler` and
37 :meth:`loop.remove_signal_handler` are not supported.
38
39:class:`SelectorEventLoop` has the following limitations:
40
41* :class:`~selectors.SelectSelector` is used to wait on socket events:
42 it supports sockets and is limited to 512 sockets.
43
44* :meth:`loop.add_reader` and :meth:`loop.add_writer` only accept
45 socket handles (e.g. pipe file descriptors are not supported).
46
47* Pipes are not supported, so the :meth:`loop.connect_read_pipe`
48 and :meth:`loop.connect_write_pipe` methods are not implemented.
49
50* :ref:`Subprocesses <asyncio-subprocess>` are not supported, i.e.
51 :meth:`loop.subprocess_exec` and :meth:`loop.subprocess_shell`
52 methods are not implemented.
53
54:class:`ProactorEventLoop` has the following limitations:
55
56* The :meth:`loop.create_datagram_endpoint` method
57 is not supported.
58
59* The :meth:`loop.add_reader` and :meth:`loop.add_writer`
60 methods are not supported.
61
62The resolution of the monotonic clock on Windows is usually around 15.6
63msec. The best resolution is 0.5 msec. The resolution depends on the
64hardware (availability of `HPET
65<https://en.wikipedia.org/wiki/High_Precision_Event_Timer>`_) and on the
66Windows configuration.
67
68
69.. _asyncio-windows-subprocess:
70
71Subprocess Support on Windows
72-----------------------------
73
Victor Stinner6ea29c52018-09-25 08:27:08 -070074On Windows, the default event loop :class:`ProactorEventLoop` supports
75subprocesses, whereas :class:`SelectorEventLoop` does not.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070076
77The :meth:`policy.set_child_watcher()
78<AbstractEventLoopPolicy.set_child_watcher>` function is also
79not supported, as :class:`ProactorEventLoop` has a different mechanism
80to watch child processes.
81
82
83macOS
84=====
85
86Modern macOS versions are fully supported.
87
88.. rubric:: macOS <= 10.8
89
90On macOS 10.6, 10.7 and 10.8, the default event loop
91uses :class:`selectors.KqueueSelector`, which does not support
92character devices on these versions. The :class:`SelectorEventLoop`
93can be manually configured to use :class:`~selectors.SelectSelector`
94or :class:`~selectors.PollSelector` to support character devices on
95these older versions of macOS. Example::
96
97 import asyncio
98 import selectors
99
100 selector = selectors.SelectSelector()
101 loop = asyncio.SelectorEventLoop(selector)
102 asyncio.set_event_loop(loop)