[New-bugs-announce] [issue43884] Cannot cleanly kill a subprocess using high-level asyncio APIs

Ronal Abraham report at bugs.python.org
Sun Apr 18 22:47:38 EDT 2021


New submission from Ronal Abraham <ronalabraham at gmail.com>:

There doesn't appear to be a way to prematurely kill a subprocess using the high-level asyncio subprocess APIs (https://docs.python.org/3.9/library/asyncio-subprocess.html) without getting a traceback on exit.

On exit, the attached program writes the following to stderr:

$ python3.9 kill_subprocess.py

Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x1065f0dc0>
Traceback (most recent call last):
    ...
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

If I uncomment `# process._transport.close()` or comment `asyncio.sleep(1)`, the walkback disappears. (I get the same behavior in python 3.8. I haven't tried other python versions.)

----------
components: asyncio
files: kill_subprocess.py
messages: 391349
nosy: asvetlov, rabraham, yselivanov
priority: normal
severity: normal
status: open
title: Cannot cleanly kill a subprocess using high-level asyncio APIs
type: behavior
versions: Python 3.8, Python 3.9
Added file: https://bugs.python.org/file49965/kill_subprocess.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43884>
_______________________________________


More information about the New-bugs-announce mailing list