blob: f8ecb58d3a01b6afa918bd468fa268f8b9a53fcc [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
26All 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 Pranskevichus1fa2ec42018-09-17 19:16:44 -040030 The :data:`socket.AF_UNIX` socket family is specific to Unix.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070031
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
58The resolution of the monotonic clock on Windows is usually around 15.6
59msec. The best resolution is 0.5 msec. The resolution depends on the
60hardware (availability of `HPET
61<https://en.wikipedia.org/wiki/High_Precision_Event_Timer>`_) and on the
62Windows configuration.
63
64
65.. _asyncio-windows-subprocess:
66
67Subprocess Support on Windows
68-----------------------------
69
Carol Willinga3c8ba72018-09-13 16:14:41 -070070:class:`SelectorEventLoop` on Windows does not support subproceses.
71On Windows, :class:`ProactorEventLoop` should be used instead::
Yury Selivanov7c7605f2018-09-11 09:54:40 -070072
73 import asyncio
74
75 asyncio.set_event_loop_policy(
76 asyncio.WindowsProactorEventLoopPolicy())
77
78 asyncio.run(your_code())
79
80
81The :meth:`policy.set_child_watcher()
82<AbstractEventLoopPolicy.set_child_watcher>` function is also
83not supported, as :class:`ProactorEventLoop` has a different mechanism
84to watch child processes.
85
86
87macOS
88=====
89
90Modern macOS versions are fully supported.
91
92.. rubric:: macOS <= 10.8
93
94On macOS 10.6, 10.7 and 10.8, the default event loop
95uses :class:`selectors.KqueueSelector`, which does not support
96character devices on these versions. The :class:`SelectorEventLoop`
97can be manually configured to use :class:`~selectors.SelectSelector`
98or :class:`~selectors.PollSelector` to support character devices on
99these 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)