diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-02-16 16:45:46 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-02-16 16:45:46 +0000 |
commit | a1be90b564f93d29df2ef89411f2928ff7b411e9 (patch) | |
tree | ee6f3a6b22df93de444c0b16993e5a5f52f76913 | |
parent | 2c143b962d10ec21dbf2624d428ea71a00fb28b3 (diff) | |
download | morph-a1be90b564f93d29df2ef89411f2928ff7b411e9.tar.gz |
scripts/distbuild: Add the ability to manually start a process
This allows you to run one of the processes under an interactive
debugger.
-rwxr-xr-x | scripts/distbuild | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/scripts/distbuild b/scripts/distbuild index 97798831..74be8c37 100755 --- a/scripts/distbuild +++ b/scripts/distbuild @@ -59,7 +59,7 @@ def subdir(workdir, *path_components): class Process(subprocess.Popen): '''A running subprocess.''' - def __init__(self, name, argv, settings, **kwargs): + def __init__(self, name, argv, settings, manual_start=False, **kwargs): '''Start a new subprocess, using subprocess.Popen. The 'name' parameter is only used internally. @@ -72,11 +72,21 @@ class Process(subprocess.Popen): self.name = name self.argv = argv self.settings = settings + self.manual_start = manual_start full_argv = argv + self._format_settings(settings) - info('%s commandline: %s' % (name, ' '.join(full_argv))) - super(Process, self).__init__(full_argv, **kwargs) - info('%s process ID: %s' % (name, self.pid)) + + if manual_start: + # This is useful if you want to interactively debug one of the + # processes. + print('Start process manually: %s' % ( + ' '.join(argv + self._format_settings(settings)))) + self.poll = lambda: None + self.returncode = None + else: + info('%s commandline: %s' % (name, ' '.join(full_argv))) + super(Process, self).__init__(full_argv, **kwargs) + info('%s process ID: %s' % (name, self.pid)) def _format_settings(self, arg_dict): def as_string(key, value): @@ -222,10 +232,15 @@ class ProcessMonitor(object): def terminate_all(self): '''Send TERM signal to all active subprocesses.''' for p in self.process.itervalues(): + if p.manual_start: + continue if p.poll() == None: p.terminate() - info('Waiting for process %i' % p.pid) + info('%s: Waiting for process %i' % (p.name, p.pid)) p.wait() + else: + info('%s: Process %i already exited with code %i' % ( + p.name, p.pid, p.returncode)) class DistbuildTestHarness(cliapp.Application): |