Skip to content

Commit 1c4dfae

Browse files
Anselm KruisAnselm Kruis
authored andcommitted
Stackless issue python#184: skip TestInterpreterShutdown at high load
The test case test_shutdown.TestInterpreterShutdown runs during interpreter shutdown and fails at high load.
1 parent 441c7d8 commit 1c4dfae

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Stackless/unittests/test_shutdown.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,25 @@ def other_thread():
468468
self.assertEqual(rc, 42)
469469

470470

471+
def is_high_load():
472+
try:
473+
sched_getaffinity = os.sched_getaffinity
474+
except AttributeError:
475+
ncpus = os.cpu_count()
476+
if ncpus is None:
477+
return False
478+
else:
479+
ncpus = len(sched_getaffinity(0))
480+
try:
481+
load = os.getloadavg()[0]
482+
except (OSError, AttributeError):
483+
return False
484+
if ncpus <= 1:
485+
return load > 0.5
486+
return load + 1 > ncpus
487+
488+
489+
@unittest.skipIf(is_high_load(), "system load is to high for this test")
471490
class TestInterpreterShutdown(unittest.TestCase):
472491
# intentionally not a subclass of StacklessTestCase.
473492

0 commit comments

Comments
 (0)