プラットフォームでのサポート

asyncio モジュールは可搬的であるようにデザインされていますが、いくつかのプラットフォームでは、その根底にあるアーキテクチャや性能による微妙な動作の違いや制限があります。

全てのプラットホーム

Windows

ソースコード: Lib/asyncio/proactor_events.py, Lib/asyncio/windows_events.py, Lib/asyncio/windows_utils.py


バージョン 3.8 で変更: Windows では ProactorEventLoop がデフォルトのイベントループになりました。

全ての Windows 上のイベントループは以下のメソッドをサポートしません:

SelectorEventLoop は以下の制限があります:

ProactorEventLoop は以下の制限があります:

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

Windows におけるサブプロセスのサポート

Windows において、デフォルトのイベントループ ProactorEventLoop はサブプロセスをサポートしますが、 SelectorEventLoop はサポートしません。

policy.set_child_watcher() 関数もサポートされません。 ProactorEventLoop は子プロセスを監視するための異なる仕組みを持っています。

macOS

最近の macOS バージョンは完全にサポートされています。

10.8 以前の macOS

macOS 10.6, 10.7 および 10.8 では、デフォルトイベントループは selectors.KqueueSelector をしていますが、このクラスはこれらの macOS バージョンのキャラクターデバイスをサポートしていません。これらの macOS バージョンでキャラクターデバイスをサポートするためには SelectorEventLoopSelectSelector または PollSelector を使うように手動で設定します。以下はその例です:

import asyncio
import selectors

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