平台支持

asyncio module is designed to be portable, but some platforms have subtle differences and limitations due to the platforms’ underlying architecture and capabilities.

All Platforms

Windows

源代码: Lib/asyncio/proactor_events.py , Lib/asyncio/windows_events.py , Lib/asyncio/windows_utils.py


3.8 版改变: 在 Windows, ProactorEventLoop is now the default event loop.

All event loops on Windows do not support the following methods:

SelectorEventLoop has the following limitations:

ProactorEventLoop has the following limitations:

The resolution of the monotonic clock on Windows is usually around 15.6 msec. The best resolution is 0.5 msec. The resolution depends on the hardware (availability of HPET ) and on the Windows configuration.

Windows 中的子进程支持

On Windows, the default event loop ProactorEventLoop supports subprocesses, whereas SelectorEventLoop does not.

policy.set_child_watcher() function is also not supported, as ProactorEventLoop has a different mechanism to watch child processes.

macOS

Modern macOS versions are fully supported.

macOS <= 10.8

On macOS 10.6, 10.7 and 10.8, the default event loop uses selectors.KqueueSelector , which does not support character devices on these versions. The SelectorEventLoop can be manually configured to use SelectSelector or PollSelector to support character devices on these older versions of macOS. Example:

import asyncio
import selectors
selector = selectors.SelectSelector()
loop = asyncio.SelectorEventLoop(selector)
asyncio.set_event_loop(loop)
								

内容表

上一话题

策略

下一话题

高级 API 索引

本页