mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Python issue #23173: sync with Tulip
* If an exception is raised during the creation of a subprocess, kill the subprocess (close pipes, kill and read the return status). Log an error in such case. * Fix SubprocessStreamProtocol.connection_made() to handle cancelled waiter. Add unit test cancelling subprocess methods.
This commit is contained in:
parent
c2c12e433a
commit
f651a60407
3 changed files with 100 additions and 25 deletions
|
@ -251,6 +251,42 @@ class SubprocessMixin:
|
|||
|
||||
self.loop.run_until_complete(cancel_wait())
|
||||
|
||||
def test_cancel_make_subprocess_transport_exec(self):
|
||||
@asyncio.coroutine
|
||||
def cancel_make_transport():
|
||||
coro = asyncio.create_subprocess_exec(*PROGRAM_BLOCKED,
|
||||
loop=self.loop)
|
||||
task = self.loop.create_task(coro)
|
||||
|
||||
self.loop.call_soon(task.cancel)
|
||||
try:
|
||||
yield from task
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
|
||||
# ignore the log:
|
||||
# "Exception during subprocess creation, kill the subprocess"
|
||||
with test_utils.disable_logger():
|
||||
self.loop.run_until_complete(cancel_make_transport())
|
||||
|
||||
def test_cancel_post_init(self):
|
||||
@asyncio.coroutine
|
||||
def cancel_make_transport():
|
||||
coro = self.loop.subprocess_exec(asyncio.SubprocessProtocol,
|
||||
*PROGRAM_BLOCKED)
|
||||
task = self.loop.create_task(coro)
|
||||
|
||||
self.loop.call_soon(task.cancel)
|
||||
try:
|
||||
yield from task
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
|
||||
# ignore the log:
|
||||
# "Exception during subprocess creation, kill the subprocess"
|
||||
with test_utils.disable_logger():
|
||||
self.loop.run_until_complete(cancel_make_transport())
|
||||
|
||||
|
||||
if sys.platform != 'win32':
|
||||
# Unix
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue