Author: Amaury Forgeot d'Arc <amaur...@gmail.com> Branch: Changeset: r47645:dbe24f2e28bc Date: 2011-09-27 23:24 +0200 http://bitbucket.org/pypy/pypy/changeset/dbe24f2e28bc/
Log: Implement _multiprocessing.SemLock._after_fork(). will it finally prevent test_multiprocessing from blocking? diff --git a/pypy/module/_multiprocessing/interp_semaphore.py b/pypy/module/_multiprocessing/interp_semaphore.py --- a/pypy/module/_multiprocessing/interp_semaphore.py +++ b/pypy/module/_multiprocessing/interp_semaphore.py @@ -468,6 +468,9 @@ self.count -= 1 + def after_fork(self): + self.count = 0 + @unwrap_spec(kind=int, maxvalue=int) def rebuild(space, w_cls, w_handle, kind, maxvalue): self = space.allocate_instance(W_SemLock, w_cls) @@ -512,6 +515,7 @@ acquire = interp2app(W_SemLock.acquire), release = interp2app(W_SemLock.release), _rebuild = interp2app(W_SemLock.rebuild.im_func, as_classmethod=True), + _after_fork = interp2app(W_SemLock.after_fork), __enter__=interp2app(W_SemLock.enter), __exit__=interp2app(W_SemLock.exit), SEM_VALUE_MAX=SEM_VALUE_MAX, diff --git a/pypy/module/_multiprocessing/test/test_semaphore.py b/pypy/module/_multiprocessing/test/test_semaphore.py --- a/pypy/module/_multiprocessing/test/test_semaphore.py +++ b/pypy/module/_multiprocessing/test/test_semaphore.py @@ -39,6 +39,10 @@ sem.release() assert sem._count() == 0 + sem.acquire() + sem._after_fork() + assert sem._count() == 0 + def test_recursive(self): from _multiprocessing import SemLock kind = self.RECURSIVE _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit