Skip to content

Commit

Permalink
stop launch on event_stop
Browse files Browse the repository at this point in the history
  • Loading branch information
lirazsiri committed Aug 10, 2011
1 parent a1f230a commit 6515423
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cloudtask/executor.py
Expand Up @@ -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()

Expand Down Expand Up @@ -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.