• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. currentmodule:: asyncio
2
3
4.. _asyncio-platform-support:
5
6
7================
8Platform Support
9================
10
11The :mod:`asyncio` module is designed to be portable,
12but some platforms have subtle differences and limitations
13due to the platforms' underlying architecture and capabilities.
14
15
16All Platforms
17=============
18
19* :meth:`loop.add_reader` and :meth:`loop.add_writer`
20  cannot be used to monitor file I/O.
21
22
23Windows
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
36All 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 :data:`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
65The resolution of the monotonic clock on Windows is usually around 15.6
66msec.  The best resolution is 0.5 msec. The resolution depends on the
67hardware (availability of `HPET
68<https://en.wikipedia.org/wiki/High_Precision_Event_Timer>`_) and on the
69Windows configuration.
70
71
72.. _asyncio-windows-subprocess:
73
74Subprocess Support on Windows
75-----------------------------
76
77On Windows, the default event loop :class:`ProactorEventLoop` supports
78subprocesses, whereas :class:`SelectorEventLoop` does not.
79
80The :meth:`policy.set_child_watcher()
81<AbstractEventLoopPolicy.set_child_watcher>` function is also
82not supported, as :class:`ProactorEventLoop` has a different mechanism
83to watch child processes.
84
85
86macOS
87=====
88
89Modern macOS versions are fully supported.
90
91.. rubric:: macOS <= 10.8
92
93On macOS 10.6, 10.7 and 10.8, the default event loop
94uses :class:`selectors.KqueueSelector`, which does not support
95character devices on these versions.  The :class:`SelectorEventLoop`
96can be manually configured to use :class:`~selectors.SelectSelector`
97or :class:`~selectors.PollSelector` to support character devices on
98these 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)
106