summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Morrow <andrew.morrow@viam.com>2024-01-19 21:15:55 (GMT)
committerAndrew Morrow <andrew.morrow@viam.com>2024-01-19 21:15:55 (GMT)
commitd932ba3700305f82ffafba6137da99b3145b82d2 (patch)
treeaae26286fcb3f01d05516ecd518c9a008cc53af4
parent2b4dafee6be6834deb04484d4e6ff23355cee627 (diff)
downloadSCons-d932ba3700305f82ffafba6137da99b3145b82d2.zip
SCons-d932ba3700305f82ffafba6137da99b3145b82d2.tar.gz
SCons-d932ba3700305f82ffafba6137da99b3145b82d2.tar.bz2
Fix JobTests.py
-rw-r--r--SCons/Taskmaster/JobTests.py45
1 files changed, 1 insertions, 44 deletions
diff --git a/SCons/Taskmaster/JobTests.py b/SCons/Taskmaster/JobTests.py
index c457e78..52118d9 100644
--- a/SCons/Taskmaster/JobTests.py
+++ b/SCons/Taskmaster/JobTests.py
@@ -202,6 +202,7 @@ class Taskmaster:
self.parallel_list = [0] * (n+1)
self.found_parallel = False
self.Task = Task
+ self.trace = False
# 'guard' guards 'task_begin_list' and 'task_end_list'
try:
@@ -284,50 +285,6 @@ class ParallelTestCase(JobTestCase):
self.assertFalse(taskmaster.num_failed,
"some task(s) failed to execute")
- # Verify that parallel jobs will pull all of the completed tasks
- # out of the queue at once, instead of one by one. We do this by
- # replacing the default ThreadPool class with one that records the
- # order in which tasks are put() and get() to/from the pool, and
- # which sleeps a little bit before call get() to let the initial
- # tasks complete and get their notifications on the resultsQueue.
-
- class SleepTask(Task):
- def _do_something(self) -> None:
- time.sleep(0.01)
-
- global SaveThreadPool
- SaveThreadPool = SCons.Taskmaster.Job.ThreadPool
-
- class WaitThreadPool(SaveThreadPool):
- def put(self, task):
- ThreadPoolCallList.append('put(%s)' % task.i)
- return SaveThreadPool.put(self, task)
- def get(self):
- time.sleep(0.05)
- result = SaveThreadPool.get(self)
- ThreadPoolCallList.append('get(%s)' % result[0].i)
- return result
-
- SCons.Taskmaster.Job.ThreadPool = WaitThreadPool
-
- try:
- taskmaster = Taskmaster(3, self, SleepTask)
- jobs = SCons.Taskmaster.Job.Jobs(2, taskmaster)
- jobs.run()
-
- # The key here is that we get(1) and get(2) from the
- # resultsQueue before we put(3), but get(1) and get(2) can
- # be in either order depending on how the first two parallel
- # tasks get scheduled by the operating system.
- expect = [
- ['put(1)', 'put(2)', 'get(1)', 'get(2)', 'put(3)', 'get(3)'],
- ['put(1)', 'put(2)', 'get(2)', 'get(1)', 'put(3)', 'get(3)'],
- ]
- assert ThreadPoolCallList in expect, ThreadPoolCallList
-
- finally:
- SCons.Taskmaster.Job.ThreadPool = SaveThreadPool
-
class SerialTestCase(unittest.TestCase):
def runTest(self) -> None:
"""test a serial job"""