summaryrefslogtreecommitdiff
path: root/distbuild
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-05-05 15:02:24 (GMT)
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-05-05 15:29:15 (GMT)
commitfb5f740adeae236ba32bdac67857351054c0bae9 (patch)
tree8d692636ea033bec502bd72252420b61537f55c3 /distbuild
parent54c06f51db3558c80706b02260c6e05b28f3ebdb (diff)
downloadmorph-fb5f740adeae236ba32bdac67857351054c0bae9.tar.gz
Add cancelling to build controller
Diffstat (limited to 'distbuild')
-rw-r--r--distbuild/build_controller.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/distbuild/build_controller.py b/distbuild/build_controller.py
index a391158..c399939 100644
--- a/distbuild/build_controller.py
+++ b/distbuild/build_controller.py
@@ -235,9 +235,9 @@ class BuildController(distbuild.StateMachine):
self._maybe_notify_build_failed),
('building', self, _Abort, None, None),
('building', self, _Built, None, self._notify_build_done),
- ('building', self._initiator_connection,
- distbuild.InitiatorDisconnect, None,
- self._notify_initiator_disconnected),
+ ('building', distbuild.InitiatorConnection,
+ distbuild.InitiatorDisconnect, 'building',
+ self._maybe_notify_initiator_disconnected),
]
self.add_transitions(spec)
@@ -438,12 +438,24 @@ class BuildController(distbuild.StateMachine):
a.state = BUILDING
- def _notify_initiator_disconnected(self, event_source, disconnect):
- logging.debug("BuildController %r: initiator id %s disconnected", self,
- disconnect.id)
- cancel = BuildCancel(disconnect.id)
+ def _maybe_notify_initiator_disconnected(self, event_source, event):
+ if event.id != self._request['id']:
+ logging.debug('Heard initiator disconnect with event id %d '
+ 'but our request id is %d',
+ event.id, self._request['id'])
+ return # not for us
+
+ logging.debug("BuildController %r: initiator id %s disconnected",
+ self, event.id)
+
+ cancel_pending = distbuild.WorkerCancelPending(event.id)
+ self.mainloop.queue_event(distbuild.WorkerBuildQueuer, cancel_pending)
+
+ cancel = BuildCancel(event.id)
self.mainloop.queue_event(BuildController, cancel)
+ self.mainloop.queue_event(self, _Abort)
+
def _maybe_relay_build_waiting_for_worker(self, event_source, event):
if event.initiator_id != self._request['id']:
return # not for us