def send(self, message):
"""May be used with 'yield'. Sends 'message' to task.
If task is currently waiting with 'receive', it is resumed with
'message'. Otherwise, 'message' is queued so that next receive call will
return message.
Can also be used on remotely running tasks.
"""
if self._location:
request = _NetRequest('send', kwargs={'message': message, 'name': self._name,
'task': self._id},
dst=self._location, timeout=MsgTimeout)
# request is queued for asynchronous processing
if _Peer.send_req(request) != 0:
logger.warning('remote task at %s may not be valid', self._location)
return -1
else:
return 0
else:
return self._scheduler._resume(self, message, Pycos._AwaitMsg_)
评论列表
文章目录