blob: 7e4a70f91c6ed55f9d92ff47e306468205d68510 [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
Yury Selivanov7c7605f2018-09-11 09:54:40 -070056* The :meth:`loop.add_reader` and :meth:`loop.add_writer`
57 methods are not supported.
58
59The resolution of the monotonic clock on Windows is usually around 15.6
60msec. The best resolution is 0.5 msec. The resolution depends on the
61hardware (availability of `HPET
62<https://en.wikipedia.org/wiki/High_Precision_Event_Timer>`_) and on the
63Windows configuration.
64
65
66.. _asyncio-windows-subprocess:
67
68Subprocess Support on Windows
69-----------------------------
70
Victor Stinner6ea29c52018-09-25 08:27:08 -070071On Windows, the default event loop :class:`ProactorEventLoop` supports
72subprocesses, whereas :class:`SelectorEventLoop` does not.
Yury Selivanov7c7605f2018-09-11 09:54:40 -070073
74The :meth:`policy.set_child_watcher()
75<AbstractEventLoopPolicy.set_child_watcher>` function is also
76not supported, as :class:`ProactorEventLoop` has a different mechanism
77to watch child processes.
78
79
80macOS
81=====
82
83Modern macOS versions are fully supported.
84
85.. rubric:: macOS <= 10.8
86
87On macOS 10.6, 10.7 and 10.8, the default event loop
88uses :class:`selectors.KqueueSelector`, which does not support
89character devices on these versions. The :class:`SelectorEventLoop`
90can be manually configured to use :class:`~selectors.SelectSelector`
91or :class:`~selectors.PollSelector` to support character devices on
92these older versions of macOS. Example::
93
94 import asyncio
95 import selectors
96
97 selector = selectors.SelectSelector()
98 loop = asyncio.SelectorEventLoop(selector)
99 asyncio.set_event_loop(loop)