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 <rep...@bugs.python.org>
<http://bugs.python.org/issue23347>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to