-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as duplicate of#103847
Closed as duplicate of#103847
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
import asyncio
async def task1():
await asyncio.create_subprocess_shell(
"ls",
# Any 2 pipes are required to reproduce
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
print("task1 done")
async def task2():
raise Exception("Task 2 failed")
async def main():
# Either asyncio.gather, asyncio.TaskGroup, or asyncio.as_completed will cause the hang
print("running gather")
await asyncio.gather(task1(), task2())
print("running tg")
async with asyncio.TaskGroup() as tg:
tg.create_task(task1())
tg.create_task(task2())
print("running as_completed")
for result in asyncio.as_completed([task1(), task2()]):
await result
print("done")
if __name__ == "__main__":
asyncio.run(main())
When awaiting create_subprocess_shell
with another task that throws an exception, the subprocess await will hang indefinitely waiting for await transp._wait()
in
cpython/Lib/asyncio/unix_events.py
Line 215 in 3dfed23
await transp._wait() |
This is reproducible with either asyncio.gather
, asyncio.TaskGroup
, or asyncio.as_completed
as shown in the example. Interestingly, this requires at least 2 pipes to be attached to the program before this bug will be triggered.
CPython versions tested on:
3.13, 3.11
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done