"asyncio" --- 非同期 I/O
************************

======================================================================


Hello World!
^^^^^^^^^^^^

   import asyncio

   async def main():
       print('Hello ...')
       await asyncio.sleep(1)
       print('... World!')

   asyncio.run(main())

asyncio は **async/await** 構文を使い **並行処理の** コードを書くため
のライブラリです。

asyncio は、高性能なネットワークとウェブサーバ、データベース接続ライブ
ラリ、分散タスクキューなどの複数の非同期 Python フレームワークの基盤と
して使われています。

asyncio は多くの場合、 IOバウンドだったり高レベルの **構造化された**
ネットワークコードに完璧に適しています。

参考:

  A Conceptual Overview of asyncio
     asyncio の基本が解説されています。

asyncio は次の目的で **高レベル** API を提供しています:

* 並行に Python コルーチンを起動 し、実行全体を管理する

* ネットワーク IO と IPC を執り行う

* subprocesses を管理する

* キュー を使ってタスクを分散する

* 並列処理のコードを 同期 させる

これに加えて、 *ライブラリやフレームワークの開発者* が次のことをするた
めの **低レベル** API があります:

* ネットワーク通信 、 サブプロセス の実行、 OS シグナル の取り扱いなど
  のための非同期 API を提供する イベントループ の作成と管理を行う

* Transport を使った効率的な protocol を実装します

* コールバックを用いたライブラリと async/await 構文を使ったコードの 橋
  渡し

Availability: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは
、WebAssembly プラットフォーム を見てください。

-[ asyncio REPL ]-

*REPL* で、"asyncio" 並行コンテキストを試すことができます:

   $ python -m asyncio
   asyncio REPL ...
   Use "await" directly instead of "asyncio.run()".
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import asyncio
   >>> await asyncio.sleep(10, result='hello')
   'hello'

This REPL provides limited compatibility with "PYTHON_BASIC_REPL". It
is recommended that the default REPL is used for full functionality
and the latest features.

引数無しで 監査イベント "cpython.run_stdin" を送出します。

バージョン 3.12.5 で変更: (also 3.11.10, 3.10.15, 3.9.20, and 3.8.20)
Emits audit events.

バージョン 3.13 で変更: Uses PyREPL if possible, in which case
"PYTHONSTARTUP" is also executed. Emits audit events.

-[ リファレンス ]-


高水準 API
^^^^^^^^^^

* Runners

* コルーチンと Task

* ストリーム

* 同期プリミティブ

* サブプロセス

* キュー

* 例外

* Call Graph Introspection


低水準 API
^^^^^^^^^^

* イベントループ

* Future

* トランスポートとプロトコル

* ポリシー

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

* Extending


ガイドとチュートリアル
^^^^^^^^^^^^^^^^^^^^^^

* 高水準の API インデックス

* 低水準の API インデックス

* asyncio での開発

注釈:

  asyncio のソースコードは Lib/asyncio/ にあります。
