File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -491,10 +491,11 @@ def event_loop(request: "pytest.FixtureRequest") -> Iterator[asyncio.AbstractEve
491
491
yield loop
492
492
# Cleanup code copied from the implementation of asyncio.run()
493
493
try :
494
- asyncio .runners ._cancel_all_tasks (loop )
495
- loop .run_until_complete (loop .shutdown_asyncgens ())
496
- if sys .version_info >= (3 , 9 ):
497
- loop .run_until_complete (loop .shutdown_default_executor ())
494
+ if not loop .is_closed ():
495
+ asyncio .runners ._cancel_all_tasks (loop )
496
+ loop .run_until_complete (loop .shutdown_asyncgens ())
497
+ if sys .version_info >= (3 , 9 ):
498
+ loop .run_until_complete (loop .shutdown_default_executor ())
498
499
finally :
499
500
loop .close ()
500
501
# Call the garbage collector to trigger ResourceWarning's as soon
You can’t perform that action at this time.
0 commit comments