Commit 0f52346e authored by Richard Oudkerk's avatar Richard Oudkerk

Fix for 2d2f206d040e so that test_multiprocessing does not depend on ctypes

parent a717d563
...@@ -1109,9 +1109,13 @@ class Bunch(object): ...@@ -1109,9 +1109,13 @@ class Bunch(object):
self.n = n self.n = n
self.started = namespace.DummyList() self.started = namespace.DummyList()
self.finished = 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): 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): def task(self):
pid = os.getpid() pid = os.getpid()
...@@ -1120,8 +1124,8 @@ class Bunch(object): ...@@ -1120,8 +1124,8 @@ class Bunch(object):
self.f(*self.args) self.f(*self.args)
finally: finally:
self.finished.append(pid) self.finished.append(pid)
while not self._can_exit.value: self._can_exit.wait(30)
_wait() assert self._can_exit.is_set()
def wait_for_started(self): def wait_for_started(self):
while len(self.started) < self.n: while len(self.started) < self.n:
...@@ -1132,7 +1136,7 @@ class Bunch(object): ...@@ -1132,7 +1136,7 @@ class Bunch(object):
_wait() _wait()
def do_finish(self): def do_finish(self):
self._can_exit.value = True self._can_exit.set()
class AppendTrue(object): class AppendTrue(object):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment