[New-bugs-announce] [issue23347] asyncio: fix and refactor creation of subprocess transports

STINNER Victor report at bugs.python.org
Thu Jan 29 12:56:49 CET 2015


New submission from STINNER Victor:

Attached patch fix and refactors the creation of asyncio subprocess transports. It fixes the code handling errors.

Changes:

* Add a wait() method to wait until the child process exit

* The constructor now accepts an optional waiter parameter. The _post_init() coroutine must not be called explicitly anymore. It makes subprocess transports closer to other transports, and it gives more freedom if we want later to change completly how subprocess transports are created.

* close() now kills the process instead of kindly terminate it: the child process may ignore SIGTERM and continue to run. Call explicitly terminate() and wait() if you want to kindly terminate the child process.

* close() now logs a warning in debug mode if the process is still running and needs to be killed

* _make_subprocess_transport() is now fully asynchronous again: if the creation of the transport failed, wait asynchronously for the process eixt. Before the wait was synchronous. This change requires close() to *kill*, and not terminate, the child process.

* Remove the _kill_wait() method, replaced with a more agressive close() method. It fixes _make_subprocess_transport() on error. BaseSubprocessTransport.close() calls the close() method of pipe transports, whereas _kill_wait() closed directly pipes of the subprocess.Popen object without unregistering file descriptors from the selector (which caused severe bugs).

* These changes make subprocess.py much simpler!

wait() is a coroutine, which is something uncommon. Is it ok to start using coroutines in transports, at least for subprocess transports?

----------
components: asyncio
files: subprocess_wait.patch
keywords: patch
messages: 234963
nosy: gvanrossum, haypo, yselivanov
priority: normal
severity: normal
status: open
title: asyncio: fix and refactor creation of subprocess transports
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file37906/subprocess_wait.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23347>
_______________________________________


More information about the New-bugs-announce mailing list