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
23 Windows
24 =======
25
26 **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
32 .. versionchanged:: 3.8
33
34 On Windows, :class:`ProactorEventLoop` is now the default event loop.
35
36 All 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.
40 The :const:`socket.AF_UNIX` socket family is specific to Unix.
41
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
62 * The :meth:`loop.add_reader` and :meth:`loop.add_writer`
63 methods are not supported.
64
65 The resolution of the monotonic clock on Windows is usually around 15.6
66 milliseconds. The best resolution is 0.5 milliseconds. The resolution depends on the
67 hardware (availability of `HPET
68 <https://en.wikipedia.org/wiki/High_Precision_Event_Timer>`_) and on the
69 Windows configuration.
70
71
72 .. _asyncio-windows-subprocess:
73
74 Subprocess Support on Windows
75 -----------------------------
76
77 On Windows, the default event loop :class:`ProactorEventLoop` supports
78 subprocesses, whereas :class:`SelectorEventLoop` does not.
79
80 The :meth:`policy.set_child_watcher()
81 <AbstractEventLoopPolicy.set_child_watcher>` function is also
82 not supported, as :class:`ProactorEventLoop` has a different mechanism
83 to watch child processes.
84
85
86 macOS
87 =====
88
89 Modern macOS versions are fully supported.
90
91 .. rubric:: macOS <= 10.8
92
93 On macOS 10.6, 10.7 and 10.8, the default event loop
94 uses :class:`selectors.KqueueSelector`, which does not support
95 character devices on these versions. The :class:`SelectorEventLoop`
96 can be manually configured to use :class:`~selectors.SelectSelector`
97 or :class:`~selectors.PollSelector` to support character devices on
98 these 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)