New submission from STINNER Victor: The creation of a subprocess in asyncio is complex, it is composed of multiple steps (callbacks scheduled by call_soon, coroutines, etc.). The creation can fail because of different reasons. I guess that the most common reason is a cancellation of a task, explicitly or because of a timeout (asyncio.wait_for).
I propose to ensure that everything is cleaned up on failure, especially to kill the subprocess. This choice comes from the subprocess module, it kills the subprocess on error. Attached patch implements this change. It also fixes a bug noticed in the issue #23140: a call to waiter.set_result() in SubprocessStreamProtocol.connection_made() is not protected by a test on the future state. When I wrote the unit tests, I tried to mock subprocess.Popen to ensure that the Popen.kill() method is called, but mocking a subprocess for asyncio is complex. I chose to keep the test simple. ---------- components: asyncio files: asyncio_subprocess_kill.patch keywords: patch messages: 233486 nosy: gvanrossum, haypo, yselivanov priority: normal severity: normal status: open title: asyncio: kill the subprocess if the creation failed versions: Python 3.4, Python 3.5 Added file: http://bugs.python.org/file37608/asyncio_subprocess_kill.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23173> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com