diff options
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r-- | Lib/test/_test_multiprocessing.py | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index bb73d9e7cc..427fc0c47a 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -119,6 +119,9 @@ if CHECK_TIMINGS: else: TIMEOUT1, TIMEOUT2, TIMEOUT3 = 0.1, 0.1, 0.1 +# BaseManager.shutdown_timeout +SHUTDOWN_TIMEOUT = support.SHORT_TIMEOUT + HAVE_GETVALUE = not getattr(_multiprocessing, 'HAVE_BROKEN_SEM_GETVALUE', False) @@ -2897,7 +2900,7 @@ class _TestMyManager(BaseTestCase): ALLOWED_TYPES = ('manager',) def test_mymanager(self): - manager = MyManager() + manager = MyManager(shutdown_timeout=SHUTDOWN_TIMEOUT) manager.start() self.common(manager) manager.shutdown() @@ -2908,7 +2911,8 @@ class _TestMyManager(BaseTestCase): self.assertIn(manager._process.exitcode, (0, -signal.SIGTERM)) def test_mymanager_context(self): - with MyManager() as manager: + manager = MyManager(shutdown_timeout=SHUTDOWN_TIMEOUT) + with manager: self.common(manager) # bpo-30356: BaseManager._finalize_manager() sends SIGTERM # to the manager process if it takes longer than 1 second to stop, @@ -2916,7 +2920,7 @@ class _TestMyManager(BaseTestCase): self.assertIn(manager._process.exitcode, (0, -signal.SIGTERM)) def test_mymanager_context_prestarted(self): - manager = MyManager() + manager = MyManager(shutdown_timeout=SHUTDOWN_TIMEOUT) manager.start() with manager: self.common(manager) @@ -2978,8 +2982,8 @@ class _TestRemoteManager(BaseTestCase): @classmethod def _putter(cls, address, authkey): manager = QueueManager2( - address=address, authkey=authkey, serializer=SERIALIZER - ) + address=address, authkey=authkey, serializer=SERIALIZER, + shutdown_timeout=SHUTDOWN_TIMEOUT) manager.connect() queue = manager.get_queue() # Note that xmlrpclib will deserialize object as a list not a tuple @@ -2989,8 +2993,8 @@ class _TestRemoteManager(BaseTestCase): authkey = os.urandom(32) manager = QueueManager( - address=(socket_helper.HOST, 0), authkey=authkey, serializer=SERIALIZER - ) + address=(socket_helper.HOST, 0), authkey=authkey, serializer=SERIALIZER, + shutdown_timeout=SHUTDOWN_TIMEOUT) manager.start() self.addCleanup(manager.shutdown) @@ -2999,8 +3003,8 @@ class _TestRemoteManager(BaseTestCase): p.start() manager2 = QueueManager2( - address=manager.address, authkey=authkey, serializer=SERIALIZER - ) + address=manager.address, authkey=authkey, serializer=SERIALIZER, + shutdown_timeout=SHUTDOWN_TIMEOUT) manager2.connect() queue = manager2.get_queue() @@ -3020,7 +3024,8 @@ class _TestManagerRestart(BaseTestCase): @classmethod def _putter(cls, address, authkey): manager = QueueManager( - address=address, authkey=authkey, serializer=SERIALIZER) + address=address, authkey=authkey, serializer=SERIALIZER, + shutdown_timeout=SHUTDOWN_TIMEOUT) manager.connect() queue = manager.get_queue() queue.put('hello world') @@ -3028,7 +3033,8 @@ class _TestManagerRestart(BaseTestCase): def test_rapid_restart(self): authkey = os.urandom(32) manager = QueueManager( - address=(socket_helper.HOST, 0), authkey=authkey, serializer=SERIALIZER) + address=(socket_helper.HOST, 0), authkey=authkey, + serializer=SERIALIZER, shutdown_timeout=SHUTDOWN_TIMEOUT) try: srvr = manager.get_server() addr = srvr.address @@ -3048,7 +3054,8 @@ class _TestManagerRestart(BaseTestCase): manager.shutdown() manager = QueueManager( - address=addr, authkey=authkey, serializer=SERIALIZER) + address=addr, authkey=authkey, serializer=SERIALIZER, + shutdown_timeout=SHUTDOWN_TIMEOUT) try: manager.start() self.addCleanup(manager.shutdown) @@ -3059,7 +3066,8 @@ class _TestManagerRestart(BaseTestCase): # (sporadic failure on buildbots) time.sleep(1.0) manager = QueueManager( - address=addr, authkey=authkey, serializer=SERIALIZER) + address=addr, authkey=authkey, serializer=SERIALIZER, + shutdown_timeout=SHUTDOWN_TIMEOUT) if hasattr(manager, "shutdown"): self.addCleanup(manager.shutdown) |