Author: Matti Picus <[email protected]>
Branch: release-pypy2.7-v7.x
Changeset: r97621:f6503c320810
Date: 2019-09-27 08:33 +0300
http://bitbucket.org/pypy/pypy/changeset/f6503c320810/

Log:    merge default into release

diff --git a/extra_tests/test_semlock.py b/extra_tests/test_semlock.py
new file mode 100644
--- /dev/null
+++ b/extra_tests/test_semlock.py
@@ -0,0 +1,26 @@
+from _multiprocessing import SemLock
+from threading import Thread
+import time
+
+
+def test_notify_all():
+    """A low-level variation on test_notify_all() in lib-python's
+    test_multiprocessing.py
+    """
+    N_THREADS = 1000
+    lock = SemLock(0, 1, 1)
+    results = []
+
+    def f(n):
+        if lock.acquire(timeout=5.):
+            results.append(n)
+            lock.release()
+
+    threads = [Thread(target=f, args=(i,)) for i in range(N_THREADS)]
+    with lock:
+        for t in threads:
+            t.start()
+        time.sleep(0.1)
+    for t in threads:
+        t.join()
+    assert len(results) == N_THREADS
diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -72,10 +72,13 @@
             default=False, dest="applevel_rewrite",
             help="Use assert rewriting in app-level test files (slow)")
 
[email protected](scope='class')
+def spaceconfig(request):
+    return getattr(request.cls, 'spaceconfig', {})
+
 @pytest.fixture(scope='function')
-def space(request):
+def space(spaceconfig):
     from pypy.tool.pytest.objspace import gettestobjspace
-    spaceconfig = getattr(request.cls, 'spaceconfig', {})
     return gettestobjspace(**spaceconfig)
 
 
diff --git a/pypy/doc/release-v7.2.0.rst b/pypy/doc/release-v7.2.0.rst
--- a/pypy/doc/release-v7.2.0.rst
+++ b/pypy/doc/release-v7.2.0.rst
@@ -14,7 +14,7 @@
 The interpreters are based on much the same codebase, thus the double
 release.
 
-With the support of ARM Holdings Ltd. and `Crossbar.io`_, this release supports
+With the support of Arm Holdings Ltd. and `Crossbar.io`_, this release supports
 the 64-bit ``aarch64`` ARM architecture. More about the work and the
 performance data around this welcome development can be found in the `blog
 post`_.
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
@@ -33,7 +33,7 @@
     _ReleaseSemaphore = rwin32.winexternal(
         'ReleaseSemaphore', [rwin32.HANDLE, rffi.LONG, rffi.LONGP],
         rwin32.BOOL,
-        save_err=rffi.RFFI_SAVE_LASTERROR)
+        save_err=rffi.RFFI_SAVE_LASTERROR, releasegil=True)
 
 else:
     from rpython.rlib import rposix
@@ -98,7 +98,7 @@
                          save_err=rffi.RFFI_SAVE_ERRNO)
     _sem_trywait = external('sem_trywait', [SEM_T], rffi.INT,
                             save_err=rffi.RFFI_SAVE_ERRNO)
-    _sem_post = external('sem_post', [SEM_T], rffi.INT,
+    _sem_post = external('sem_post', [SEM_T], rffi.INT, releasegil=False,
                          save_err=rffi.RFFI_SAVE_ERRNO)
     _sem_getvalue = external('sem_getvalue', [SEM_T, rffi.INTP], rffi.INT,
                              save_err=rffi.RFFI_SAVE_ERRNO)
@@ -374,7 +374,7 @@
                     elif e.errno in (errno.EAGAIN, errno.ETIMEDOUT):
                         return False
                     raise
-                _check_signals(space)    
+                _check_signals(space)
                 self.last_tid = rthread.get_ident()
                 self.count += 1
                 return True
@@ -487,7 +487,7 @@
             # sets self.last_tid and increments self.count
             # those steps need to be as close as possible to
             # acquiring the semlock for self._ismine() to support
-            # multiple threads 
+            # multiple threads
             got = semlock_acquire(self, space, block, w_timeout)
         except OSError as e:
             raise wrap_oserror(space, e)
@@ -507,6 +507,8 @@
                 return
 
         try:
+            # Note: a succesful semlock_release() must not release the GIL,
+            # otherwise there is a race condition on self.count
             semlock_release(self, space)
             self.count -= 1
         except OSError as e:
diff --git a/pypy/module/_multiprocessing/test/test_interp_semaphore.py 
b/pypy/module/_multiprocessing/test/test_interp_semaphore.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_multiprocessing/test/test_interp_semaphore.py
@@ -0,0 +1,48 @@
+import pytest
+import time
+from rpython.rlib.rgil import yield_thread
+from pypy.tool.pytest.objspace import gettestobjspace
+from pypy.interpreter.gateway import interp2app
+from pypy.module.thread.os_lock import allocate_lock
+from pypy.module.thread.os_thread import start_new_thread
+from pypy.module._multiprocessing.interp_semaphore import (
+    create_semaphore, sem_unlink, W_SemLock)
+
[email protected]('spaceconfig', [
+    {'usemodules': ['_multiprocessing', 'thread']}])
+def test_semlock_release(space):
+    sem_name = '/test7'
+    _handle = create_semaphore(space, sem_name, 1, 1)
+    w_lock = W_SemLock(space, _handle, 0, 1)
+    created = []
+    successful = []
+    N_THREADS = 16
+
+    def run(space):
+        w_sentinel = allocate_lock(space)
+        yield_thread()
+        w_sentinel.descr_lock_acquire(space)  # releases GIL
+        yield_thread()
+        created.append(w_sentinel)
+        w_got = w_lock.acquire(space, w_timeout=space.newfloat(5.))  # 
releases GIL
+        if space.is_true(w_got):
+            yield_thread()
+            w_lock.release(space)
+            successful.append(w_sentinel)
+        w_sentinel.descr_lock_release(space)
+    w_run = space.wrap(interp2app(run))
+
+    w_lock.acquire(space)
+    for _ in range(N_THREADS):
+        start_new_thread(space, w_run, space.newtuple([]))  # releases GIL
+    deadline = time.time() + 5.
+    while len(created) < N_THREADS:
+        assert time.time() < deadline
+        yield_thread()
+    w_lock.release(space)
+
+    for w_sentinel in created:
+        # Join thread
+        w_sentinel.descr_lock_acquire(space)  # releases GIL
+        w_sentinel.descr_lock_release(space)
+    assert len(successful) == N_THREADS
diff --git a/pypy/tool/pytest/test/test_appsupport.py 
b/pypy/tool/pytest/test/test_appsupport.py
--- a/pypy/tool/pytest/test/test_appsupport.py
+++ b/pypy/tool/pytest/test/test_appsupport.py
@@ -40,22 +40,38 @@
         "*AppTestMethod*",
     ])
 
-class TestSpaceConfig:
-    def test_interp_spaceconfig(self, testdir):
-        setpypyconftest(testdir)
-        p = testdir.makepyfile("""
-            class TestClass:
-                spaceconfig = {"objspace.usemodules._random": False}
-                def setup_class(cls):
-                    assert not cls.space.config.objspace.usemodules._random
-                def test_interp(self, space):
-                    assert self.space is space
-                def test_interp2(self, space):
-                    assert self.space is space
-        """)
-        result = testdir.runpytest(p)
-        assert result.ret == 0
-        result.stdout.fnmatch_lines(["*2 passed*"])
+def test_interp_spaceconfig(testdir):
+    setpypyconftest(testdir)
+    p = testdir.makepyfile("""
+        class TestClass:
+            spaceconfig = {"objspace.usemodules._random": False}
+            def setup_class(cls):
+                assert not cls.space.config.objspace.usemodules._random
+            def test_interp(self, space):
+                assert self.space is space
+            def test_interp2(self, space):
+                assert self.space is space
+    """)
+    result = testdir.runpytest(p)
+    assert result.ret == 0
+    result.stdout.fnmatch_lines(["*2 passed*"])
+
+def test_spaceconfig_param(testdir):
+    setpypyconftest(testdir)
+    p = testdir.makepyfile("""
+        import pytest
+
+        @pytest.mark.parametrize('spaceconfig',
+            [{"objspace.usemodules._random": False}])
+        def test_interp(space):
+            assert not space.config.objspace.usemodules._random
+
+        def test_interp2(space):
+            assert space.config.objspace.usemodules._random
+    """)
+    result = testdir.runpytest(p)
+    assert result.ret == 0
+    result.stdout.fnmatch_lines(["*2 passed*"])
 
 def test_applevel_raises_simple_display(testdir):
     setpypyconftest(testdir)
diff --git a/pypy/tool/release/force-builds.py 
b/pypy/tool/release/force-builds.py
--- a/pypy/tool/release/force-builds.py
+++ b/pypy/tool/release/force-builds.py
@@ -28,6 +28,7 @@
     'own-win-x86-32',
     'own-linux-s390x',
 #    'own-macosx-x86-32',
+    'own-linux-aarch64',
     'pypy-c-jit-linux-x86-32',
     'pypy-c-jit-linux-x86-64',
 #    'pypy-c-jit-freebsd-9-x86-64',
@@ -36,6 +37,7 @@
     'pypy-c-jit-linux-s390x',
 #    'build-pypy-c-jit-linux-armhf-raspbian',
 #    'build-pypy-c-jit-linux-armel',
+    'pypy-c-jit-linux-aarch64',
     'rpython-linux-x86-32',
     'rpython-linux-x86-64',
     'rpython-win-x86-32'
diff --git a/pypy/tool/release/repackage.sh b/pypy/tool/release/repackage.sh
--- a/pypy/tool/release/repackage.sh
+++ b/pypy/tool/release/repackage.sh
@@ -28,7 +28,7 @@
 # Download latest builds from the buildmaster, rename the top
 # level directory, and repackage ready to be uploaded to bitbucket
 actual_ver=xxxxxxxxxxxxxxx
-for plat in linux linux64 osx64 s390x # linux-armhf-raspbian linux-armel
+for plat in linux linux64 osx64 s390x aarch64 # linux-armhf-raspbian 
linux-armel
   do
     echo downloading package for $plat
     if wget -q --show-progress 
http://buildbot.pypy.org/nightly/$branchname/pypy-c-jit-latest-$plat.tar.bz2
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to