[pypy-commit] pypy py3k: consider the new gil as an impl detail for now

pjenvey noreply at buildbot.pypy.org
Fri Jul 19 00:48:46 CEST 2013


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r65474:e40e1af13fd0
Date: 2013-07-18 15:44 -0700
http://bitbucket.org/pypy/pypy/changeset/e40e1af13fd0/

Log:	consider the new gil as an impl detail for now

diff --git a/lib-python/3/test/test_sys.py b/lib-python/3/test/test_sys.py
--- a/lib-python/3/test/test_sys.py
+++ b/lib-python/3/test/test_sys.py
@@ -190,6 +190,8 @@
                 sys.setcheckinterval(n)
                 self.assertEqual(sys.getcheckinterval(), n)
 
+    @unittest.skipUnless(hasattr(sys, 'setswitchinterval'),
+                         'The new GIL is an implementation detail')
     @unittest.skipUnless(threading, 'Threading required for this test.')
     def test_switchinterval(self):
         self.assertRaises(TypeError, sys.setswitchinterval)
diff --git a/lib-python/3/test/test_threading.py b/lib-python/3/test/test_threading.py
--- a/lib-python/3/test/test_threading.py
+++ b/lib-python/3/test/test_threading.py
@@ -346,10 +346,15 @@
         # Try hard to trigger #1703448: a thread is still returned in
         # threading.enumerate() after it has been join()ed.
         enum = threading.enumerate
-        old_interval = sys.getswitchinterval()
+        newgil = hasattr(sys, 'getswitchinterval')
+        if newgil:
+            geti, seti = sys.getswitchinterval, sys.setswitchinterval
+        else:
+            geti, seti = sys.getcheckinterval, sys.setcheckinterval
+        old_interval = geti()
         try:
             for i in range(1, 100):
-                sys.setswitchinterval(i * 0.0002)
+                seti(i * 0.0002 if newgil else i // 5)
                 t = threading.Thread(target=lambda: None)
                 t.start()
                 t.join()
@@ -357,7 +362,7 @@
                 self.assertNotIn(t, l,
                     "#1703448 triggered after %d trials: %s" % (i, l))
         finally:
-            sys.setswitchinterval(old_interval)
+            seti(old_interval)
 
     @test.support.cpython_only
     def test_no_refcycle_through_target(self):


More information about the pypy-commit mailing list