Author: Matti Picus <[email protected]>
Branch:
Changeset: r97624:000e74685f0b
Date: 2019-09-27 12:17 +0300
http://bitbucket.org/pypy/pypy/changeset/000e74685f0b/
Log: adjust test for systems with limited threads
diff --git a/extra_tests/test_semlock.py b/extra_tests/test_semlock.py
--- a/extra_tests/test_semlock.py
+++ b/extra_tests/test_semlock.py
@@ -1,5 +1,6 @@
from _multiprocessing import SemLock
from threading import Thread
+import thread
import time
@@ -17,10 +18,19 @@
lock.release()
threads = [Thread(target=f, args=(i,)) for i in range(N_THREADS)]
+ n_started = N_THREADS
with lock:
for t in threads:
- t.start()
+ try:
+ t.start()
+ except thread.error:
+ # too many threads for this system
+ t.started = False
+ n_started -= 1
+ else:
+ t.started = True
time.sleep(0.1)
for t in threads:
- t.join()
- assert len(results) == N_THREADS
+ if t.started:
+ t.join()
+ assert len(results) == n_started
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit