Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Open
Description
Bug report
Bug description:
This is a toy program that sets an asyncio.Event when a signal is received, and runs an asynchronous function (passive_wait
) that waits for that signal to be set.
When the following code is executed and a signal is sent externally, it is detected by the program, but the function waiting function does not resume execution.
It does finish correctly if another async function is executed alongside, like when uncommenting the lineactive_wait(),
.
importasyncioimportsignalevent=asyncio.Event()def_signal_handler(*_)->None:event.set()print("Event triggered")signal.signal(signal.SIGINT,_signal_handler)signal.signal(signal.SIGTERM,_signal_handler)asyncdefpassive_wait():print("Pre event")awaitevent.wait()print("Post event")asyncdefactive_wait():whilenotevent.is_set():awaitasyncio.sleep(1)asyncdefmain():awaitasyncio.gather(passive_wait(),# Uncommenting the following line makes it stop correctly#active_wait(), )asyncio.run(main())# Send the signal externally
If that's the intended behavior I would love some pointers.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Projects
Status
Todo