[pypy-svn] r74262 - in pypy/trunk/pypy/module/thread: . test

benjamin at codespeak.net benjamin at codespeak.net
Fri Apr 30 01:27:08 CEST 2010


Author: benjamin
Date: Fri Apr 30 01:27:06 2010
New Revision: 74262

Modified:
   pypy/trunk/pypy/module/thread/ll_thread.py
   pypy/trunk/pypy/module/thread/test/test_ll_thread.py
Log:
always deal with ident as a long

Modified: pypy/trunk/pypy/module/thread/ll_thread.py
==============================================================================
--- pypy/trunk/pypy/module/thread/ll_thread.py	(original)
+++ pypy/trunk/pypy/module/thread/ll_thread.py	Fri Apr 30 01:27:06 2010
@@ -35,10 +35,10 @@
         ident = thread.start_new_thread(func, ())
     except thread.error:
         ident = -1
-    return rffi.cast(rffi.INT, ident)
+    return rffi.cast(rffi.LONG, ident)
 
 CALLBACK = lltype.Ptr(lltype.FuncType([], lltype.Void))
-c_thread_start = llexternal('RPyThreadStart', [CALLBACK], rffi.INT,
+c_thread_start = llexternal('RPyThreadStart', [CALLBACK], rffi.LONG,
                             _callable=_emulated_start_new_thread,
                             threadsafe=True)  # release the GIL, but most
                                               # importantly, reacquire it

Modified: pypy/trunk/pypy/module/thread/test/test_ll_thread.py
==============================================================================
--- pypy/trunk/pypy/module/thread/test/test_ll_thread.py	(original)
+++ pypy/trunk/pypy/module/thread/test/test_ll_thread.py	Fri Apr 30 01:27:06 2010
@@ -47,15 +47,16 @@
                 state.freed_counter += 1
 
         def bootstrap():
-            state.my_thread_ident = get_ident()
+            state.my_thread_ident = state.z.ident = get_ident()
             assert state.my_thread_ident == get_ident()
+            assert get_ident() == state.z.ident
             state.seen_value = state.z.value
             state.z = None
             state.done = 1
 
         def g(i):
             state.z = Z(i)
-            start_new_thread(bootstrap, ())
+            return start_new_thread(bootstrap, ())
         g._dont_inline_ = True
 
         def f():
@@ -65,7 +66,7 @@
             for i in range(50):
                 state.done = 0
                 state.seen_value = 0
-                g(i)
+                ident = g(i)
                 gc.collect()
                 willing_to_wait_more = 1000
                 while not state.done:
@@ -74,6 +75,7 @@
                         raise Exception("thread didn't start?")
                     time.sleep(0.01)
                 assert state.my_thread_ident != main_ident
+                assert state.my_thread_ident == ident
                 assert state.seen_value == i
             # try to force Boehm to do some freeing
             for i in range(3):



More information about the Pypy-commit mailing list