Fix dangling warning for test_multiprocessing

This commit is contained in:
Richard Oudkerk 2012-05-03 18:29:02 +01:00
parent bf4e266397
commit a6becaa9cb
2 changed files with 7 additions and 1 deletions

View File

@ -548,7 +548,10 @@ class BaseManager(object):
'''
Join the manager process (if it has been spawned)
'''
self._process.join(timeout)
if self._process is not None:
self._process.join(timeout)
if not self._process.is_alive():
self._process = None
def _debug_info(self):
'''

View File

@ -2516,6 +2516,7 @@ class TestInitializers(unittest.TestCase):
def tearDown(self):
self.mgr.shutdown()
self.mgr.join()
def test_manager_initializer(self):
m = multiprocessing.managers.SyncManager()
@ -2523,6 +2524,7 @@ class TestInitializers(unittest.TestCase):
m.start(initializer, (self.ns,))
self.assertEqual(self.ns.test, 1)
m.shutdown()
m.join()
def test_pool_initializer(self):
self.assertRaises(TypeError, multiprocessing.Pool, initializer=1)
@ -2818,6 +2820,7 @@ def test_main(run=None):
ManagerMixin.pool.terminate()
ManagerMixin.pool.join()
ManagerMixin.manager.shutdown()
ManagerMixin.manager.join()
ThreadsMixin.pool.join()
ProcessesMixin.pool.join()
del ProcessesMixin.pool, ThreadsMixin.pool, ManagerMixin.pool