8000 bpo-35621: Support running subprocesses in asyncio when loop is executed in non-main thread by asvetlov · Pull Request #14344 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-35621: Support running subprocesses in asyncio when loop is executed in non-main thread #14344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update docs
  • Loading branch information
asvetlov committed Jun 30, 2019
commit cc5a7522791045ff9432333b8e98c4d44ff349fb
7 changes: 3 additions & 4 deletions Doc/library/asyncio-policy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ implementation used by the asyncio event loop:

This implementation starts a new waiting thread for every subprocess spawn.

The watcher can be used by asyncio code executed in non-main thread without any
limitation.
It works reliably even when the asyncio event loop is run in a non-main OS thread.

There is no noticeable overhead when handling a big number of children (*O(1)* each
time a child terminates), but stating a thread per process requires extra memory.
Expand All @@ -219,8 +218,8 @@ implementation used by the asyncio event loop:
.. class:: MultiLoopChildWatcher

This implementation registers a :py:data:`SIGCHLD` signal handler on
instantiation. That can break third-party code that installs a custom handler for `SIGCHLD`.
signal).
instantiation. That can break third-party code that installs a custom handler for
`SIGCHLD`. signal).

The watcher avoids disrupting other code spawning processes
by polling every process explicitly on a :py:data:`SIGCHLD` signal.
Expand Down
3 changes: 3 additions & 0 deletions Doc/library/asyncio-subprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ On UNIX *child watchers* are used for subprocess finish waiting, see
UNIX switched to use :class:`ThreadedChildWatcher` for spawning subprocesses from
different threads without any limitation.

Spawning a subprocess with *inactive* current child watcher raises
:exc:`RuntimeError`.

Note that alternative event loop implementations might have own limitations;
please refer to their documentation.

Expand Down
0