Bug report
Bug description:
The internal subprocess pipe-connect task registers no awaited_by edge
Repro:
import asyncio, sys
async def main():
spawn = asyncio.create_task(
asyncio.create_subprocess_exec(sys.executable, '-c', 'pass',
stdin=asyncio.subprocess.PIPE),
name='spawn')
await asyncio.sleep(0)
await asyncio.sleep(0)
for t in asyncio.all_tasks() - {asyncio.current_task()}:
asyncio.print_call_graph(t)
proc = await spawn
await proc.wait()
asyncio.run(main())
Actual:
* Task(name='spawn', id=0x103e00b90)
+ Call stack:
| File '/Users/timofeiivankov/cpython/Lib/asyncio/unix_events.py', line 211, in async _UnixSelectorEventLoop._make_subprocess_transport()
| File '/Users/timofeiivankov/cpython/Lib/asyncio/base_events.py', line 1839, in async BaseEventLoop.subprocess_exec()
| File '/Users/timofeiivankov/cpython/Lib/asyncio/subprocess.py', line 249, in async create_subprocess_exec()
* Task(name='Task-2', id=0x103b7d0a0)
+ Call stack:
| File '/Users/timofeiivankov/cpython/Lib/asyncio/base_events.py', line 1753, in async BaseEventLoop.connect_write_pipe()
| File '/Users/timofeiivankov/cpython/Lib/asyncio/base_subprocess.py', line 188, in async BaseSubprocessTransport._connect_pipes()
Expected:
* Task(name='spawn', id=0x105620b90)
+ Call stack:
| File '/Users/timofeiivankov/cpython/Lib/asyncio/unix_events.py', line 211, in async _UnixSelectorEventLoop._make_subprocess_transport()
| File '/Users/timofeiivankov/cpython/Lib/asyncio/base_events.py', line 1839, in async BaseEventLoop.subprocess_exec()
| File '/Users/timofeiivankov/cpython/Lib/asyncio/subprocess.py', line 249, in async create_subprocess_exec()
* Task(name='Task-2', id=0x10539d0a0)
+ Call stack:
| File '/Users/timofeiivankov/cpython/Lib/asyncio/base_events.py', line 1753, in async BaseEventLoop.connect_write_pipe()
| File '/Users/timofeiivankov/cpython/Lib/asyncio/base_subprocess.py', line 194, in async BaseSubprocessTransport._connect_pipes()
+ Awaited by:
* Task(name='spawn', id=0x105620b90)
+ Call stack:
| File '/Users/timofeiivankov/cpython/Lib/asyncio/unix_events.py', line 211, in async _UnixSelectorEventLoop._make_subprocess_transport()
| File '/Users/timofeiivankov/cpython/Lib/asyncio/base_events.py', line 1839, in async BaseEventLoop.subprocess_exec()
| File '/Users/timofeiivankov/cpython/Lib/asyncio/subprocess.py', line 249, in async create_subprocess_exec()
Proposed fix: register the edge in BaseSubprocessTransport.__init__ and discard it in doe callback
I have a fix ready for that
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Bug report
Bug description:
The internal subprocess pipe-connect task registers no awaited_by edge
Repro:
Actual:
Expected:
Proposed fix: register the edge in
BaseSubprocessTransport.__init__and discard it in doe callbackI have a fix ready for that
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS