This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Cannot properly close terminated process
Type: Stage:
Components: asyncio Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, hniksic, yselivanov
Priority: normal Keywords:

Created on 2018-12-19 20:35 by hniksic, last changed 2022-04-11 14:59 by admin.

File name Uploaded Description Edit hniksic, 2018-12-19 20:35
Messages (1)
msg332165 - (view) Author: Hrvoje Nikšić (hniksic) * Date: 2018-12-19 20:35
It seems impossible to correctly close() an asyncio Process on which terminate has been invoked. Take the following coroutine:

async def test():
    proc = await asyncio.create_subprocess_shell(
        "sleep 1", stdout=asyncio.subprocess.PIPE)
    await proc.wait()

After running it with, Python prints a warning about "Event loop is closed" exception ignored in BaseSubprocessTransport.__del__. The code does wait for the process to exit, and neither proc nor proc.stdout have a close() method, so the warning seems spurious.

Commenting out proc.terminate() makes the program finish without an exception (but then it waits for a full second, of course).

Runnable example attached.
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79720
2018-12-19 20:35:52hniksiccreate