From d0143c276f31bf9de26dfbe92d64693cdcbd2014 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Wed, 11 Feb 2015 12:13:41 +0000 Subject: distbuild: Fix case where 'computing build graph' would hang forever If there's no distbuild-helper process running on the controller then the controller would hang forever. This situation is unlikely, but it's important to give the user feedback instead of silently hanging forever. --- distbuild/build_controller.py | 3 +++ distbuild/mainloop.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/distbuild/build_controller.py b/distbuild/build_controller.py index cfa0e2e2..8dbbaef9 100644 --- a/distbuild/build_controller.py +++ b/distbuild/build_controller.py @@ -246,6 +246,9 @@ class BuildController(distbuild.StateMachine): def _request_command_execution(self, argv, request_id): '''Tell the controller's distbuild-helper to run a command.''' + if self.mainloop.n_state_machines_of_type(distbuild.HelperRouter) == 0: + self.fail('No distbuild-helper process running on controller!') + msg = distbuild.message('exec-request', id=request_id, argv=argv, diff --git a/distbuild/mainloop.py b/distbuild/mainloop.py index f0e5eebc..8c46b2fb 100644 --- a/distbuild/mainloop.py +++ b/distbuild/mainloop.py @@ -56,7 +56,10 @@ class MainLoop(object): def remove_state_machine(self, machine): logging.debug('MainLoop.remove_state_machine: %s' % machine) self._machines.remove(machine) - + + def n_state_machines_of_type(self, machine_type): + return len([m for m in self._machines if isinstance(m, machine_type)]) + def add_event_source(self, event_source): logging.debug('MainLoop.add_event_source: %s' % event_source) self._sources.append(event_source) -- cgit v1.2.1