@@ -477,24 +477,27 @@ def test_webagg():
477
477
inspect .getsource (_test_interactive_impl )
478
478
+ "\n _test_interactive_impl()" , "{}" ],
479
479
env = {** os .environ , "MPLBACKEND" : "webagg" , "SOURCE_DATE_EPOCH" : "0" })
480
- url = "http://{}:{}" .format (
481
- mpl .rcParams ["webagg.address" ], mpl .rcParams ["webagg.port" ])
480
+ url = f'http://{ mpl .rcParams ["webagg.address" ]} :{ mpl .rcParams ["webagg.port" ]} '
482
481
timeout = time .perf_counter () + _test_timeout
483
- while True :
484
- try :
485
- retcode = proc .poll ()
486
- # check that the subprocess for the server is not dead
487
- assert retcode is None
488
- conn = urllib .request .urlopen (url )
489
- break
490
- except urllib .error .URLError :
491
- if time .perf_counter () > timeout :
492
- pytest .fail ("Failed to connect to the webagg server." )
493
- else :
494
- continue
495
- conn .close ()
496
- proc .send_signal (signal .SIGINT )
497
- assert proc .wait (timeout = _test_timeout ) == 0
482
+ try :
483
+ while True :
484
+ try :
485
+ retcode = proc .poll ()
486
+ # check that the subprocess for the server is not dead
487
+ assert retcode is None
488
+ conn = urllib .request .urlopen (url )
489
+ break
490
+ except urllib .error .URLError :
491
+ if time .perf_counter () > timeout :
492
+ pytest .fail ("Failed to connect to the webagg server." )
493
+ else :
494
+ continue
495
+ conn .close ()
496
+ proc .send_signal (signal .SIGINT )
497
+ assert proc .wait (timeout = _test_timeout ) == 0
498
+ finally :
499
+ if proc .poll () is None :
500
+ proc .kill ()
498
501
499
502
500
503
def _lazy_headless ():
0 commit comments