asyncio-glib icon indicating copy to clipboard operation
asyncio-glib copied to clipboard

Asyncio subprocess EOF is never received

Open nielsavonds opened this issue 5 years ago • 0 comments

When running a subprocess using asyncio-glib and having stdout as a PIPE, the EOF is never received. This happens because the selector doesn't listen for the GLib HUP signal.

A minimal non-working example:

import asyncio
from asyncio import subprocess

from asyncio_glib import GLibEventLoopPolicy


async def main():
    proc = await asyncio.create_subprocess_exec('ls', '-la', '/tmp', stdout=subprocess.PIPE)

    async for line in proc.stdout:
        print(line)

    print('DONE')

if __name__ == '__main__':
    asyncio.set_event_loop_policy(GLibEventLoopPolicy())
    asyncio.run(main())

The print('DONE') line is never reached. When running this wihtout the GLibEventLoopPolicy, it does work.

nielsavonds avatar May 15 '20 08:05 nielsavonds