File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -530,20 +530,25 @@ def test_run_until_complete_loop(self):
530
530
other_loop .run_until_complete , task )
531
531
532
532
def test_run_until_complete_loop_orphan_future_close_loop (self ):
533
- async def foo ( sec = 0 ):
534
- await asyncio . sleep ( sec )
533
+ class ShowStopper ( BaseException ):
534
+ pass
535
535
536
- self .loop .close ()
537
- loop = asyncio .new_event_loop ()
538
- asyncio .set_event_loop (loop )
536
+ async def foo (delay ):
537
+ await asyncio .sleep (delay , loop = self .loop )
538
+
539
+ def throw ():
540
+ raise ShowStopper
541
+
542
+ self .loop ._process_events = mock .Mock ()
543
+ self .loop .call_soon (throw )
539
544
try :
540
- with mock .patch ('asyncio.base_events.BaseEventLoop.run_forever' ,
541
- side_effect = Exception ):
542
- loop .run_until_complete (foo ())
543
- except :
545
+ self .loop .run_until_complete (foo (0.1 ))
546
+ except ShowStopper :
544
547
pass
545
- loop .run_until_complete (foo (0.1 ))
546
- loop .close ()
548
+
549
+ # This call fails if run_until_complete does not clean up
550
+ # done-callback for the previous future.
551
+ self .loop .run_until_complete (foo (0.2 ))
547
552
548
553
def test_subprocess_exec_invalid_args (self ):
549
554
args = [sys .executable , '-c' , 'pass' ]
You can’t perform that action at this time.
0 commit comments