|
|
@ -66,16 +66,23 @@ def main(router):
|
|
|
|
# Select will wake it up -- be it a message arriving on the status
|
|
|
|
# Select will wake it up -- be it a message arriving on the status
|
|
|
|
# receiver, or any message arriving on any of the function call result
|
|
|
|
# receiver, or any message arriving on any of the function call result
|
|
|
|
# receivers.
|
|
|
|
# receivers.
|
|
|
|
both_sel = mitogen.select.Select([status_recv, calls_sel], oneshot=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Once last call is completed, calls_sel will be empty since it's
|
|
|
|
# Once last call is completed, calls_sel will be empty since it's
|
|
|
|
# oneshot=True (the default), causing __bool__ to be False
|
|
|
|
# oneshot=True (the default), causing __bool__ to be False
|
|
|
|
|
|
|
|
both_sel = mitogen.select.Select([status_recv, calls_sel], oneshot=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Internally selects store a strong reference from Receiver->Select that
|
|
|
|
|
|
|
|
# will keep the Select alive as long as the receiver is alive. If a
|
|
|
|
|
|
|
|
# receiver or select otherwise 'outlives' some parent select, attempting to
|
|
|
|
|
|
|
|
# re-add it to a new select will raise an error. In all cases it's
|
|
|
|
|
|
|
|
# desirable to call Select.close(). This can be done as a context manager.
|
|
|
|
|
|
|
|
with calls_sel, both_sel:
|
|
|
|
while calls_sel:
|
|
|
|
while calls_sel:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
msg = both_sel.get(timeout=60.0)
|
|
|
|
msg = both_sel.get(timeout=60.0)
|
|
|
|
except mitogen.core.TimeoutError:
|
|
|
|
except mitogen.core.TimeoutError:
|
|
|
|
print("No update in 60 seconds, something's broke")
|
|
|
|
print("No update in 60 seconds, something's broke")
|
|
|
|
raise Crash()
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
hostname = hostname_by_context_id[msg.src_id]
|
|
|
|
hostname = hostname_by_context_id[msg.src_id]
|
|
|
|
|
|
|
|
|
|
|
@ -90,4 +97,7 @@ def main(router):
|
|
|
|
except mitogen.core.CallError as e:
|
|
|
|
except mitogen.core.CallError as e:
|
|
|
|
print('Task failed on host %s: %s' % (hostname, e))
|
|
|
|
print('Task failed on host %s: %s' % (hostname, e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if calls_sel:
|
|
|
|
|
|
|
|
print('Some tasks did not complete.')
|
|
|
|
|
|
|
|
else:
|
|
|
|
print('All tasks completed.')
|
|
|
|
print('All tasks completed.')
|
|
|
|