Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 399c59d

Browse files
committed
asyncio doc: list limitations to run subprocesses from different threads
1 parent 15cc678 commit 399c59d

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Doc/library/asyncio-dev.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ the event loop.
7474
The :ref:`Synchronization primitives <asyncio-sync>` section describes ways
7575
to synchronize tasks.
7676

77+
The :ref:`Subprocess and threads <asyncio-subprocess-threads>` section lists
78+
asyncio limitations to run subprocesses from different threads.
79+
80+
81+
7782

7883
.. _asyncio-handle-blocking:
7984

Doc/library/asyncio-subprocess.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,25 @@ Process
297297
``N`` (Unix only).
298298

299299

300+
.. _asyncio-subprocess-threads:
301+
302+
Subprocess and threads
303+
======================
304+
305+
asyncio supports running subprocesses from different threads, but there
306+
are limits:
307+
308+
* An event loop must run in the main thread
309+
* The child watcher must be instantiated in the main thread, before executing
310+
subprocesses from other threads. Call the :func:`get_child_watcher`
311+
function in the main thread to instantiate the child watcher.
312+
313+
.. seealso::
314+
315+
The :ref:`Concurrency and multithreading in asyncio
316+
<asyncio-multithreading>` section.
317+
318+
300319
Subprocess examples
301320
===================
302321

0 commit comments

Comments
 (0)