[pypy-svn] r46353 - pypy/dist/pypy/module/thread/test
arigo at codespeak.net
arigo at codespeak.net
Wed Sep 5 18:47:09 CEST 2007
Author: arigo
Date: Wed Sep 5 18:47:08 2007
New Revision: 46353
Modified:
pypy/dist/pypy/module/thread/test/support.py
pypy/dist/pypy/module/thread/test/test_local.py
pypy/dist/pypy/module/thread/test/test_thread.py
Log:
These tests are quite slow. One of them timed out on wyvern,
so I'm adding a way to increase the default timeout again...
Modified: pypy/dist/pypy/module/thread/test/support.py
==============================================================================
--- pypy/dist/pypy/module/thread/test/support.py (original)
+++ pypy/dist/pypy/module/thread/test/support.py Wed Sep 5 18:47:08 2007
@@ -4,10 +4,12 @@
from pypy.interpreter.gateway import ObjSpace, W_Root, interp2app_temp
-def waitfor(space, w_condition, timeout=300.0):
+NORMAL_TIMEOUT = 300.0 # 5 minutes
+
+def waitfor(space, w_condition, delay=1):
w_sleep = space.appexec([], "():\n import time; return time.sleep")
adaptivedelay = 0.04
- limit = time.time() + timeout
+ limit = time.time() + delay * NORMAL_TIMEOUT
while time.time() <= limit:
space.call_function(w_sleep, space.wrap(adaptivedelay))
gc.collect()
@@ -25,9 +27,9 @@
cls.space = space
if option.runappdirect:
- def plain_waitfor(condition, timeout=300.0):
+ def plain_waitfor(condition, delay=1):
adaptivedelay = 0.04
- limit = time.time() + timeout
+ limit = time.time() + NORMAL_TIMEOUT * delay
while time.time() <= limit:
time.sleep(adaptivedelay)
gc.collect()
@@ -43,28 +45,3 @@
import time
return time.sleep
""")
-
-## cls.w_waitfor = space.appexec([], """():
-## import time
-## def waitfor(expr, timeout=10.0):
-## limit = time.time() + timeout
-## while time.time() <= limit:
-## time.sleep(0.002)
-## if expr():
-## return
-## print '*** timed out ***'
-## return waitfor
-## """)
-## cls.w_busywait = space.appexec([], """():
-## import time
-## def busywait(t):
-## limit = time.time() + t
-## while time.time() <= limit:
-## time.sleep(0.002)
-## return busywait
-## """)
-
-## space.appexec([], """():
-## import sys
-## sys.setcheckinterval(1)
-## """)
Modified: pypy/dist/pypy/module/thread/test/test_local.py
==============================================================================
--- pypy/dist/pypy/module/thread/test/test_local.py (original)
+++ pypy/dist/pypy/module/thread/test/test_local.py Wed Sep 5 18:47:08 2007
@@ -32,7 +32,7 @@
ok.append(success)
for i in range(20):
thread.start_new_thread(f, (i,))
- self.waitfor(lambda: len(ok) == 20) #, timeout=30.0)
+ self.waitfor(lambda: len(ok) == 20, delay=3)
assert ok == 20*[True] # see stdout/stderr for failures in the threads
self.waitfor(lambda: len(freed) >= 40)
@@ -62,7 +62,7 @@
seen.append(x.tag)
for i in range(5):
thread.start_new_thread(f, ())
- self.waitfor(lambda: len(seen) == 5) #, timeout=20.0)
+ self.waitfor(lambda: len(seen) == 5, delay=2)
seen1 = seen[:]
seen1.sort()
assert seen1 == [1, 2, 3, 4, 5]
@@ -82,5 +82,5 @@
done.append(1)
for i in range(5):
thread.start_new_thread(f, (i,))
- self.waitfor(lambda: len(done) == 5) #, timeout=20.0)
+ self.waitfor(lambda: len(done) == 5, delay=2)
assert len(done) == 5
Modified: pypy/dist/pypy/module/thread/test/test_thread.py
==============================================================================
--- pypy/dist/pypy/module/thread/test/test_thread.py (original)
+++ pypy/dist/pypy/module/thread/test/test_thread.py Wed Sep 5 18:47:08 2007
@@ -138,6 +138,6 @@
thread.start_new_thread(f, (i, done))
done_marker.append(done)
for done in done_marker:
- self.waitfor(lambda: done) #, timeout=30.0)
+ self.waitfor(lambda: done, delay=3)
assert done # see stderr for failures in threads
assert sorted(lst) == range(120)
More information about the Pypy-commit
mailing list