]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix for 2d2f206d040e so that test_multiprocessing does not depend on ctypes
authorRichard Oudkerk <shibturn@gmail.com>
Fri, 15 Jun 2012 18:18:30 +0000 (19:18 +0100)
committerRichard Oudkerk <shibturn@gmail.com>
Fri, 15 Jun 2012 18:18:30 +0000 (19:18 +0100)
Lib/test/test_multiprocessing.py

index 6da55749b693653e1339ab00166e0aac863aad1e..e4031f6927756496c9233adb2fa91aead9976862 100644 (file)
@@ -1109,9 +1109,13 @@ class Bunch(object):
         self.n = n
         self.started = namespace.DummyList()
         self.finished = namespace.DummyList()
-        self._can_exit = namespace.Value('i', not wait_before_exit)
+        self._can_exit = namespace.Event()
+        if not wait_before_exit:
+            self._can_exit.set()
         for i in range(n):
-            namespace.Process(target=self.task).start()
+            p = namespace.Process(target=self.task)
+            p.daemon = True
+            p.start()
 
     def task(self):
         pid = os.getpid()
@@ -1120,8 +1124,8 @@ class Bunch(object):
             self.f(*self.args)
         finally:
             self.finished.append(pid)
-            while not self._can_exit.value:
-                _wait()
+            self._can_exit.wait(30)
+            assert self._can_exit.is_set()
 
     def wait_for_started(self):
         while len(self.started) < self.n:
@@ -1132,7 +1136,7 @@ class Bunch(object):
             _wait()
 
     def do_finish(self):
-        self._can_exit.value = True
+        self._can_exit.set()
 
 
 class AppendTrue(object):