[pypy-svn] r77895 - in pypy/branch/fast-forward/pypy/module/_multiprocessing: . test

afa at codespeak.net afa at codespeak.net
Thu Oct 14 00:59:28 CEST 2010


Author: afa
Date: Thu Oct 14 00:59:27 2010
New Revision: 77895

Modified:
   pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_semaphore.py
   pypy/branch/fast-forward/pypy/module/_multiprocessing/test/test_semaphore.py
Log:
Test and fix with recursive mutex


Modified: pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_semaphore.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_semaphore.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_semaphore.py	Thu Oct 14 00:59:27 2010
@@ -354,6 +354,7 @@
 
     def semlock_release(self, space):
         if self.kind == RECURSIVE_MUTEX:
+            sem_post(self.handle)
             return
         if HAVE_BROKEN_SEM_GETVALUE:
             # We will only check properly the maxvalue == 1 case

Modified: pypy/branch/fast-forward/pypy/module/_multiprocessing/test/test_semaphore.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_multiprocessing/test/test_semaphore.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_multiprocessing/test/test_semaphore.py	Thu Oct 14 00:59:27 2010
@@ -7,6 +7,7 @@
         space = gettestobjspace(usemodules=('_multiprocessing', 'thread'))
         cls.space = space
         cls.w_SEMAPHORE = space.wrap(SEMAPHORE)
+        cls.w_RECURSIVE = space.wrap(RECURSIVE_MUTEX)
 
     def test_semaphore(self):
         from _multiprocessing import SemLock
@@ -31,6 +32,26 @@
         sem.release()
         assert sem._count() == 0
 
+    def test_recursive(self):
+        from _multiprocessing import SemLock
+        kind = self.RECURSIVE
+        value = 1
+        maxvalue = 1
+        sem = SemLock(kind, value, maxvalue)
+
+        sem.acquire()
+        sem.release()
+        assert sem._count() == 0
+        sem.acquire()
+        sem.release()
+
+        # now recursively
+        sem.acquire()
+        sem.acquire()
+        assert sem._count() == 2
+        sem.release()
+        sem.release()
+
     def test_semaphore_wait(self):
         from _multiprocessing import SemLock
         kind = self.SEMAPHORE



More information about the Pypy-commit mailing list