[pypy-commit] pypy py3.5: expose sem_unlink on posix platforms (multiprocessing) to run the stdlib tests

plan_rich pypy.commits at gmail.com
Thu Oct 13 11:23:37 EDT 2016


Author: Richard Plangger <planrichi at gmail.com>
Branch: py3.5
Changeset: r87761:71fd4ec38feb
Date: 2016-10-13 17:22 +0200
http://bitbucket.org/pypy/pypy/changeset/71fd4ec38feb/

Log:	expose sem_unlink on posix platforms (multiprocessing) to run the
	stdlib tests

diff --git a/pypy/module/_multiprocessing/__init__.py b/pypy/module/_multiprocessing/__init__.py
--- a/pypy/module/_multiprocessing/__init__.py
+++ b/pypy/module/_multiprocessing/__init__.py
@@ -7,7 +7,7 @@
     interpleveldefs = {
         'Connection'      : 'interp_connection.W_FileConnection',
         'SemLock'         : 'interp_semaphore.W_SemLock',
-
+        'sem_unlink'      : 'interp_semaphore.semaphore_unlink',
         'address_of_buffer' : 'interp_memory.address_of_buffer',
     }
 
@@ -18,6 +18,7 @@
         interpleveldefs['PipeConnection'] = \
             'interp_connection.W_PipeConnection'
         interpleveldefs['win32'] = 'interp_win32.win32_namespace(space)'
+        del interpleveldefs['sem_unlink']
 
     def init(self, space):
         MixedModule.init(self, space)
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
@@ -211,6 +211,12 @@
     def handle_w(space, w_handle):
         return rffi.cast(SEM_T, space.int_w(w_handle))
 
+    def semaphore_unlink(space, w_name):
+        name = space.str_w(w_name)
+        res = _sem_unlink(name)
+        if res < 0:
+            raise oefmt(space.w_OSError, "sem unlink failed with errno: %d", rposix.get_saved_errno())
+
 class CounterState:
     def __init__(self, space):
         self.counter = 0
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
@@ -1,3 +1,4 @@
+import py
 import sys
 
 from pypy.module._multiprocessing.interp_semaphore import (
@@ -18,6 +19,12 @@
         cls.w_SEMAPHORE = cls.space.wrap(SEMAPHORE)
         cls.w_RECURSIVE = cls.space.wrap(RECURSIVE_MUTEX)
 
+    @py.test.mark.skipif("sys.platform == 'win32'")
+    def test_sem_unlink(self):
+        from _multiprocessing import sem_unlink
+        try: sem_unlink("non-existent")
+        except OSError: pass
+
     def test_semaphore(self):
         from _multiprocessing import SemLock
         import sys
diff --git a/pypy/module/thread/threadlocals.py b/pypy/module/thread/threadlocals.py
--- a/pypy/module/thread/threadlocals.py
+++ b/pypy/module/thread/threadlocals.py
@@ -7,6 +7,7 @@
 
 
 ExecutionContext._signals_enabled = 0     # default value
+ExecutionContext._sentinel_lock = None
 
 
 class OSThreadLocals:


More information about the pypy-commit mailing list