def terminate(self):
"""Terminate task.
If this method called by a thread (and not a task), there is a chance
that task being terminated is currently running and can interfere with
GenratorExit exception that will be thrown to task.
Can also be used on remotely running tasks.
"""
if self._location:
request = _NetRequest('terminate_task', kwargs={'task': self._id, 'name': self._name},
dst=self._location, timeout=MsgTimeout)
if _Peer.send_req(request) != 0:
logger.warning('remote task at %s may not be valid', self._location)
return -1
return 0
else:
return self._scheduler._terminate_task(self)
评论列表
文章目录