@@ -2817,6 +2817,7 @@ def test_remote(self):
28172817 address = (test .support .HOST , 0 ), authkey = authkey , serializer = SERIALIZER
28182818 )
28192819 manager .start ()
2820+ self .addCleanup (manager .shutdown )
28202821
28212822 p = self .Process (target = self ._putter , args = (manager .address , authkey ))
28222823 p .daemon = True
@@ -2836,7 +2837,6 @@ def test_remote(self):
28362837
28372838 # Make queue finalizer run before the server is stopped
28382839 del queue
2839- manager .shutdown ()
28402840
28412841class _TestManagerRestart (BaseTestCase ):
28422842
@@ -2852,25 +2852,29 @@ def test_rapid_restart(self):
28522852 authkey = os .urandom (32 )
28532853 manager = QueueManager (
28542854 address = (test .support .HOST , 0 ), authkey = authkey , serializer = SERIALIZER )
2855- srvr = manager .get_server ()
2856- addr = srvr .address
2857- # Close the connection.Listener socket which gets opened as a part
2858- # of manager.get_server(). It's not needed for the test.
2859- srvr .listener .close ()
2860- manager .start ()
2855+ try :
2856+ srvr = manager .get_server ()
2857+ addr = srvr .address
2858+ # Close the connection.Listener socket which gets opened as a part
2859+ # of manager.get_server(). It's not needed for the test.
2860+ srvr .listener .close ()
2861+ manager .start ()
28612862
2862- p = self .Process (target = self ._putter , args = (manager .address , authkey ))
2863- p .start ()
2864- p .join ()
2865- queue = manager .get_queue ()
2866- self .assertEqual (queue .get (), 'hello world' )
2867- del queue
2868- manager .shutdown ()
2863+ p = self .Process (target = self ._putter , args = (manager .address , authkey ))
2864+ p .start ()
2865+ p .join ()
2866+ queue = manager .get_queue ()
2867+ self .assertEqual (queue .get (), 'hello world' )
2868+ del queue
2869+ finally :
2870+ if hasattr (manager , "shutdown" ):
2871+ manager .shutdown ()
28692872
28702873 manager = QueueManager (
28712874 address = addr , authkey = authkey , serializer = SERIALIZER )
28722875 try :
28732876 manager .start ()
2877+ self .addCleanup (manager .shutdown )
28742878 except OSError as e :
28752879 if e .errno != errno .EADDRINUSE :
28762880 raise
@@ -2879,7 +2883,8 @@ def test_rapid_restart(self):
28792883 time .sleep (1.0 )
28802884 manager = QueueManager (
28812885 address = addr , authkey = authkey , serializer = SERIALIZER )
2882- manager .shutdown ()
2886+ if hasattr (manager , "shutdown" ):
2887+ self .addCleanup (manager .shutdown )
28832888
28842889#
28852890#
0 commit comments