summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Job.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2008-04-30 05:39:46 (GMT)
committerSteven Knight <knight@baldmt.com>2008-04-30 05:39:46 (GMT)
commit889dc735eb173180dd92b0263bf5dbe697129881 (patch)
treef3178f3f085f178e22d840046acc862e23422870 /src/engine/SCons/Job.py
parentd9cca1c6bba7446bc13d90daa949fce4b364da7f (diff)
downloadSCons-889dc735eb173180dd92b0263bf5dbe697129881.zip
SCons-889dc735eb173180dd92b0263bf5dbe697129881.tar.gz
SCons-889dc735eb173180dd92b0263bf5dbe697129881.tar.bz2
Merged revisions 2898-2901,2903-2927 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core ........ r2903 | stevenknight | 2008-04-22 08:23:52 -0700 (Tue, 22 Apr 2008) | 3 lines Issue 2019: don't blow up when a "dictionary" source_scanner doesn't have a more-specific scanner entry for a specified source file's suffix. ........ r2904 | stevenknight | 2008-04-23 11:13:19 -0700 (Wed, 23 Apr 2008) | 3 lines Fix regression in use of $CXXFLAGS by the default $SHCXXFLAGS setting. (Greg Noel) ........ r2905 | stevenknight | 2008-04-23 11:23:12 -0700 (Wed, 23 Apr 2008) | 3 lines Update the test/CXX/SHCXXFLAGS.py with some more modern idioms copied from test/CXX/CXXFLAGS.py. ........ r2921 | belley | 2008-04-28 08:52:13 -0700 (Mon, 28 Apr 2008) | 98 lines Candidate list must be flushed when stopping the taskmaster. ============================================================ The taskmaster's candidate list must be flushed when the taskmaster is stopped, either because of a build error or a keyboard interrupt. This involves failing each candidates along with their waiting parents. This is necessary because the waiting parents might be in the pending_children set() that is used by the taskmaster to determine if cycles exist in the dependency graph. Failure to do so leads to confusing error messages such as: scons: *** Found dependency cycle(s): Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/DynamicProperty.h (<SCons.Node.FS.File instance at 0x95d230c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/NotSupported.h (<SCons.Node.FS.File instance at 0x960634c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/InvalidRequest.h (<SCons.Node.FS.File instance at 0x95d2bac>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/RequestCanceled.h (<SCons.Node.FS.File instance at 0x960648c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/InvalidType.h (<SCons.Node.FS.File instance at 0x95d2cec>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Core/InvalidProperty.h (<SCons.Node.FS.File instance at 0x9606d2c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/SecurityError.h (<SCons.Node.FS.File instance at 0x96065cc>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Core/PropertyCollector.h (<SCons.Node.FS.File instance at 0x9606e6c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/Fault/InvalidArgument.h (<SCons.Node.FS.File instance at 0x95d2a6c>) Internal Error: no cycle found for node /bld/vmkernel-main/scons/build/vmodl/obj/generic/Vmodl/Vmomi/DynamicData.h (<SCons.Node.FS.File instance at 0x95d21cc>) Changes made: Job.py: ------ o Implemented an InterruptState object that allows the sharing of the interrupt state between the Jobs, the Serial/Parallel and the Worker thread object. This allows for somewhat faster interruption when Ctrl-C is pressed because the Worker thread will not start any new task, i.e. the ones siting in the request queue. Taskmaster.py: -------------- o Moved the code contained the function Task.fail_continue() to the function Taskmaster.will_not_build(). This function perform the clean-up for nodes that will never be built. This includes failing these nodes along with their waiting parents and removing them from the list of pending children. o Improved the taskmaster tracing so that the pending children ref counts of nodes is also printed. o When stopping the taskmaster, no_next_candidate() now calls will_not_build() repetitively to make sure that all candidate nodes that will never be build are properly cleaned-up. test/Parallel/multiple-parents.py --------------------------------- Improved the test to also exercise the following functionality: o Nodes with multiple targets (not just aliases as it was before). o SideEffect() o Interrupting the build. Submitted against changeset 2920. All tests pass with both Python 2.5.1 and 1.5.2 Benoit ........ r2922 | stevenknight | 2008-04-28 11:50:10 -0700 (Mon, 28 Apr 2008) | 26 lines Issue 2024: http://scons.tigris.org/issues/show_bug.cgi?id=2024 Some public packages were importing specific SCons.Options.*Option submodules directly, instead of using the SCons.Options package itself (which actually exposed all the SCons.Options.*Option variable names directly, but what they hey). Our scripts didn't test for direct importing of the submodules, so this broke when I implemented backwards comptability with a SCons/Options.py module, instead of a full SCons/Options/*.py package. This restores the SCons/Options/*.py package files with stub modules that provide backwards compatibility (by referring to the new SCons.Variables functions and classes) and allow for importing all of The test/Deprecated/Options/*Option.py scripts have had specific submodule imports added. To make sure this corresponding "feature" continues to work in the future, I'll be following this with another checkin that adds submodule imports for the SCons.Variables.*Variable modules. I ran this with the SCons/Options.py file in place, and also with a compiled SCons/Options.pyc file in place, to try to make sure it works regardless. We've seen issues on Debian where their packaging doesn't clean up old *.pyc files when a Python *.py module is removed. It looks like this should work regardless of whether the Options.pyc file is there or not. ........ r2923 | stevenknight | 2008-04-28 11:52:52 -0700 (Mon, 28 Apr 2008) | 3 lines Update the test/Variables/*Variable.py scripts to verify that importing SCons.Variables.*Variable submodules continues to work in the future. ........ r2924 | belley | 2008-04-28 14:06:54 -0700 (Mon, 28 Apr 2008) | 6 lines Fixed a test that my morning change broke. The taskmaster tracing now includes the pending children ref count. Benoit ........ r2925 | stevenknight | 2008-04-28 18:00:25 -0700 (Mon, 28 Apr 2008) | 4 lines Issue 2028: Make sure already-existing Entry Nodes that we find are converted to Dir Nodes when searching a *PATH list for implicit dependencies. ........ r2926 | stevenknight | 2008-04-29 08:11:40 -0700 (Tue, 29 Apr 2008) | 3 lines Issue 2034: Fix $FORTRANMODDIR values like ${TARGET.dir} in the default $_FORTANMODFLAG expansion. (Stefano) ........ r2927 | stevenknight | 2008-04-29 11:34:02 -0700 (Tue, 29 Apr 2008) | 3 lines Restore the SCons.Options package (maintains backwards compatibility of importing submodules) to setup.py. ........
Diffstat (limited to 'src/engine/SCons/Job.py')
-rw-r--r--src/engine/SCons/Job.py38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/engine/SCons/Job.py b/src/engine/SCons/Job.py
index d93952c..545df98 100644
--- a/src/engine/SCons/Job.py
+++ b/src/engine/SCons/Job.py
@@ -49,6 +49,18 @@ default_stack_size = 256
interrupt_msg = 'Build interrupted.'
+
+class InterruptState:
+ def __init__(self):
+ self.interrupted = False
+
+ def set(self):
+ self.interrupted = True
+
+ def __call__(self):
+ return self.interrupted
+
+
class Jobs:
"""An instance of this class initializes N jobs, and provides
methods for starting, stopping, and waiting on all N jobs.
@@ -84,8 +96,6 @@ class Jobs:
self.job = Serial(taskmaster)
self.num_jobs = 1
- self.job.interrupted = False
-
def run(self, postfunc=lambda: None):
"""Run the jobs.
@@ -104,7 +114,7 @@ class Jobs:
def were_interrupted(self):
"""Returns whether the jobs were interrupted by a signal."""
- return self.job.interrupted
+ return self.job.interrupted()
def _setup_sig_handler(self):
"""Setup an interrupt handler so that SCons can shutdown cleanly in
@@ -127,10 +137,10 @@ class Jobs:
SCons forks before executing another process. In that case, we
want the child to exit immediately.
"""
- def handler(signum, stack, parentpid=os.getpid()):
+ def handler(signum, stack, self=self, parentpid=os.getpid()):
if os.getpid() == parentpid:
self.job.taskmaster.stop()
- self.job.interrupted = True
+ self.job.interrupted.set()
else:
os._exit(2)
@@ -170,6 +180,7 @@ class Serial:
execute (e.g. execute() raised an exception)."""
self.taskmaster = taskmaster
+ self.interrupted = InterruptState()
def start(self):
"""Start the job. This will begin pulling tasks from the taskmaster
@@ -188,7 +199,7 @@ class Serial:
if task.needs_execute():
task.execute()
except:
- if self.interrupted:
+ if self.interrupted():
try:
raise SCons.Errors.BuildError(
task.targets[0], errstr=interrupt_msg)
@@ -221,11 +232,12 @@ else:
dequeues the task, executes it, and posts a tuple including the task
and a boolean indicating whether the task executed successfully. """
- def __init__(self, requestQueue, resultsQueue):
+ def __init__(self, requestQueue, resultsQueue, interrupted):
threading.Thread.__init__(self)
self.setDaemon(1)
self.requestQueue = requestQueue
self.resultsQueue = resultsQueue
+ self.interrupted = interrupted
self.start()
def run(self):
@@ -239,6 +251,9 @@ else:
break
try:
+ if self.interrupted():
+ raise SCons.Errors.BuildError(
+ task.targets[0], errstr=interrupt_msg)
task.execute()
except:
task.exception_set()
@@ -251,7 +266,7 @@ else:
class ThreadPool:
"""This class is responsible for spawning and managing worker threads."""
- def __init__(self, num, stack_size):
+ def __init__(self, num, stack_size, interrupted):
"""Create the request and reply queues, and 'num' worker threads.
One must specify the stack size of the worker threads. The
@@ -277,7 +292,7 @@ else:
# Create worker threads
self.workers = []
for _ in range(num):
- worker = Worker(self.requestQueue, self.resultsQueue)
+ worker = Worker(self.requestQueue, self.resultsQueue, interrupted)
self.workers.append(worker)
# Once we drop Python 1.5 we can change the following to:
@@ -348,7 +363,8 @@ else:
multiple tasks simultaneously. """
self.taskmaster = taskmaster
- self.tp = ThreadPool(num, stack_size)
+ self.interrupted = InterruptState()
+ self.tp = ThreadPool(num, stack_size, self.interrupted)
self.maxjobs = num
@@ -395,7 +411,7 @@ else:
if ok:
task.executed()
else:
- if self.interrupted:
+ if self.interrupted():
try:
raise SCons.Errors.BuildError(
task.targets[0], errstr=interrupt_msg)