Debian Codegraph @

Doc/library/asyncio-platforms.rst

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