[pypy-svn] r17953 - pypy/dist/pypy/translator/c/test

arigo at codespeak.net arigo at codespeak.net
Thu Sep 29 00:06:00 CEST 2005


Author: arigo
Date: Thu Sep 29 00:05:57 2005
New Revision: 17953

Modified:
   pypy/dist/pypy/translator/c/test/test_extfunc.py
Log:
Difficult to test properly the complex interactions between the refcounting of
the parent and in the child thread of the object passed as an argument between
them.  The problem is that the only clean solution is like os_thread.py: the
ownership of 'arg' must be passed to the child thread, which eventually
releases it when it terminates.  But for the tests the main thread has no
clean way to wait until the child thread is entierely finished and has
released 'arg'.  So sometimes, an 'assert mallocs == frees' triggers.



Modified: pypy/dist/pypy/translator/c/test/test_extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_extfunc.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_extfunc.py	Thu Sep 29 00:05:57 2005
@@ -332,11 +332,11 @@
         assert arg.value == 42
     def myotherthreadedfunction(arg):
         assert arg.value == 43
+    a42 = Arg()
+    a42.value = 42
+    a43 = Arg()
+    a43.value = 43
     def fn(i):
-        a42 = Arg()
-        a42.value = 42
-        a43 = Arg()
-        a43.value = 43
         thread.start_new_thread(mythreadedfunction, (a42,))
         thread.start_new_thread(myotherthreadedfunction, (a43,))
         if i == 1:
@@ -356,14 +356,14 @@
     import pypy.module.thread.rpython.exttable   # for declare()/declaretype()
     class Arg:
         pass
+    a = Arg()
+    a.x = 5
+    a.lock = thread.allocate_lock()
     def mythreadedfunction(arg):
         arg.x += 37
         arg.myident = thread.get_ident()
         arg.lock.release()
     def fn():
-        a = Arg()
-        a.x = 5
-        a.lock = thread.allocate_lock()
         a.lock.acquire(True)
         ident = thread.start_new_thread(mythreadedfunction, (a,))
         assert ident != thread.get_ident()



More information about the Pypy-commit mailing list