You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
asyncio: interrupting run_until_complete makes the next run stop early #158406
Interrupting loop.run_until_complete() after its future is done means that the next run of the same loop can stop after one iteration. If the future of that run is not done by then, loop.run_until_complete() raises RuntimeError: Event loop stopped before Future completed.
The above raises RuntimeError. The expected behaviour is that no error is raised.
If I understand correctly, this is due to the callback that stops the loop being missed by remove_done_callback() and thus deferred to the next iteration of the loop due to the timing of the signal.
Thus, this also affects asyncio.run() which runs the loop again during shutdown.
@deadlovelll I have a draft fix locally that I was going to test and tidy up post sometime this week, but if you have a fix by all means open a PR first, I don't mind :)
@deadlovelll I have a draft fix locally that I was going to test and tidy up post sometime this week, but if you have a fix by all means open a PR first, I don't mind :)
It's okay, go ahead, it's your find =)
Reacted by Tom Kuson and Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి)
Activity
deadlovelll commentedon Sep 29, 2026
hey @tjkuson, i can work on this if you don't mind
tjkuson commentedon Sep 29, 2026
@deadlovelll I have a draft fix locally that I was going to test and tidy up post sometime this week, but if you have a fix by all means open a PR first, I don't mind :)
deadlovelll commentedon Sep 29, 2026
It's okay, go ahead, it's your find =)
pythongh-158406: Fix asyncio run_until_complete() making the next run…
pythongh-158406: Fix asyncio run_until_complete making the next run s…
pythongh-158406: Fix asyncio run_until_complete making the next run s…
tjkuson commentedon Nov 20, 2026
I posted #158450 to fix this issue, could someone take a look? It's been over a month and the dev guide suggests I ping here.