def monitor(self, observe):
"""Must be used with 'yield' as 'yield task.monitor(observe)', where
'observe' is a task which will be monitored by 'task'. When 'observe'
is finished (raises StopIteration or terminated due to uncaught
exception), that exception is sent as a message to 'task' (monitor
task).
Monitor can inspect the exception and restart observed task if
necessary. 'observe' can be a remote task.
Can also be used on remotely running 'observe' task.
"""
if observe._location:
# remote task
request = _NetRequest('monitor', kwargs={'monitor': self, 'name': observe._name,
'task': observe._id},
dst=observe._location, timeout=MsgTimeout)
reply = yield _Peer._sync_reply(request)
else:
reply = self._scheduler._monitor(self, observe)
raise StopIteration(reply)
评论列表
文章目录