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

afa at codespeak.net afa at codespeak.net
Mon Oct 11 18:42:03 CEST 2010


Author: afa
Date: Mon Oct 11 18:42:01 2010
New Revision: 77804

Modified:
   pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_semaphore.py
   pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py
   pypy/branch/fast-forward/pypy/module/_multiprocessing/test/test_semaphore.py
Log:
implement SemLock._rebuild()


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	Mon Oct 11 18:42:01 2010
@@ -15,6 +15,7 @@
 if sys.platform == 'win32':
     from pypy.rlib import rwin32
     from pypy.interpreter.error import wrap_windowserror
+    from pypy.module._multiprocessing.interp_win32 import handle_w
 
     SEM_VALUE_MAX = sys.maxint
 
@@ -183,6 +184,9 @@
         finally:
             lltype.free(now, flavor='raw')
 
+    def handle_w(space, w_handle):
+        return rffi.cast(SEM_T, space.uint_w(w_handle))
+
     class GlobalState:
         def init(self):
             pass
@@ -424,6 +428,12 @@
 
         self.count -= 1
 
+    @unwrap_spec('self', ObjSpace, W_Root, int, int)
+    def rebuild(self, space, w_handle, kind, maxvalue):
+        self.handle = handle_w(space, w_handle)
+        self.kind = kind
+        self.maxvalue = maxvalue
+
 @unwrap_spec(ObjSpace, W_Root, int, int, int)
 def descr_new(space, w_subtype, kind, value, maxvalue):
     if kind != RECURSIVE_MUTEX and kind != SEMAPHORE:
@@ -450,5 +460,6 @@
     _is_mine = interp2app(W_SemLock.is_mine),
     acquire = interp2app(W_SemLock.acquire),
     release = interp2app(W_SemLock.release),
+    _rebuild = interp2app(W_SemLock.rebuild),
     SEM_VALUE_MAX=SEM_VALUE_MAX,
     )

Modified: pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_multiprocessing/interp_win32.py	Mon Oct 11 18:42:01 2010
@@ -6,7 +6,7 @@
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.rpython.tool import rffi_platform
-from pypy.module._multiprocessing import w_handle
+from pypy.module._multiprocessing.interp_connection import w_handle
 
 CONSTANTS = """
     PIPE_ACCESS_INBOUND PIPE_ACCESS_DUPLEX

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	Mon Oct 11 18:42:01 2010
@@ -36,3 +36,12 @@
 
         assert sem.acquire()
         assert not sem.acquire(timeout=0.1)
+
+    def test_semaphore_rebuild(self):
+        from _multiprocessing import SemLock
+        kind = self.SEMAPHORE
+        value = 1
+        maxvalue = 1
+        sem = SemLock(kind, value, maxvalue)
+
+        sem._rebuild(sem.handle, kind, value)



More information about the Pypy-commit mailing list