[pypy-commit] pypy default: Fix the test: calling sleep() may not release the GIL before translation.

arigo noreply at buildbot.pypy.org
Sun Oct 16 17:31:21 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r48085:6048a0bf9e33
Date: 2011-10-16 16:13 +0200
http://bitbucket.org/pypy/pypy/changeset/6048a0bf9e33/

Log:	Fix the test: calling sleep() may not release the GIL before
	translation.

diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -568,20 +568,22 @@
         import thread
 
         thread_id = thread.get_ident()
-        self.ready = False
         def other_thread():
-            self.ready = True
             print "thread started"
-            time.sleep(5)
+            lock2.release()
+            lock1.acquire()
+        lock1 = thread.allocate_lock()
+        lock2 = thread.allocate_lock()
+        lock1.acquire()
+        lock2.acquire()
         thread.start_new_thread(other_thread, ())
 
         def f():
-            for i in range(100):
-                if self.ready: break
-                time.sleep(0.1)
+            lock2.acquire()
             return sys._current_frames()
 
         frames = f()
+        lock1.release()
         thisframe = frames.pop(thread_id)
         assert thisframe.f_code.co_name == 'f'
 


More information about the pypy-commit mailing list