Permalink
Browse files

stop launch on event_stop

  • Loading branch information...
1 parent a1f230a commit 6515423fed172f8eeeb74b492a604590d33bcd24 @lirazsiri lirazsiri committed Aug 10, 2011
Showing with 9 additions and 5 deletions.
  1. +9 −5 cloudtask/executor.py
View
@@ -261,21 +261,25 @@ def __init__(self, split, session, taskconf):
launchq = Queue()
def thread():
+
+ def callback():
+ return not self.event_stop.is_set()
+
hub = Hub(taskconf.hub_apikey)
i = None
try:
- for i, address in enumerate(hub.launch(new_workers, **taskconf.ec2_opts)):
+ for i, address in enumerate(hub.launch(new_workers, callback, **taskconf.ec2_opts)):
launchq.put(address)
- except hub.Error:
-
+ except hub.Error, e:
unlaunched_workers = new_workers - (i + 1) \
if i is not None \
else new_workers
for i in range(unlaunched_workers):
launchq.put(None)
- traceback.print_exc(file=session.mlog)
+ if not isinstance(e, hub.Stopped):
+ traceback.print_exc(file=session.mlog)
threading.Thread(target=thread).start()
@@ -311,4 +315,4 @@ def stop(self):
def join(self):
if self.split:
self._execute.wait(keepalive=False, keepalive_spares=1)
- self._execute.stop()
+ self.stop()

0 comments on commit 6515423

Please sign in to comment.