示例#1
0
    def ask(self, anActor, msg, timeout):
        self._ASKFAILED = None
        self.transport.scheduleTransmit(
            None, TransmitIntent(anActor, msg, onError=self._askSendFailed))

        while True:
            response = self.transport.run(None, toTimeDeltaOrNone(timeout))
            if response is None: break
            if self._ASKFAILED is not None:
                if self._ASKFAILED in [
                        SendStatus.DeadTarget, SendStatus.Failed,
                        SendStatus.NotSent
                ]:
                    # Silent failure; not all transports can indicate
                    # this, so for conformity the Dead Letter handler is
                    # the intended method of handling this issue.
                    return None
                raise ActorSystemFailure(
                    'Transmit of ask message to %s failed (%s)' %
                    (str(anActor), str(self._ASKFAILED)))
            # Do not send miscellaneous ActorSystemMessages to the caller
            # that it might not recognize.
            if response and not isInternalActorSystemMessage(response.message):
                return response.message
        return None
示例#2
0
    def ask(self, anActor, msg, timeout):
        self._ASKFAILED = None
        self.transport.scheduleTransmit(
            None,
            TransmitIntent(anActor, msg, onError = self._askSendFailed))

        while True:
            response = self.transport.run(None, toTimeDeltaOrNone(timeout))
            if response is None: break
            if self._ASKFAILED is not None:
                if self._ASKFAILED in [SendStatus.DeadTarget,
                                       SendStatus.Failed,
                                       SendStatus.NotSent]:
                    # Silent failure; not all transports can indicate
                    # this, so for conformity the Dead Letter handler is
                    # the intended method of handling this issue.
                    return None
                raise ActorSystemFailure('Transmit of ask message to %s failed (%s)'%(
                    str(anActor),
                    str(self._ASKFAILED)))
            # Do not send miscellaneous ActorSystemMessages to the caller
            # that it might not recognize.
            if response and not isInternalActorSystemMessage(response.message):
                return response.message
        return None
示例#3
0
 def listen(self, timeout):
     while True:
         response = self.transport.run(None, toTimeDeltaOrNone(timeout))
         if response is None: break
         # Do not send miscellaneous ActorSystemMessages to the caller
         # that it might not recognize.
         if response and not isInternalActorSystemMessage(response.message):
             return response.message
     return None
示例#4
0
 def listen(self, timeout):
     while True:
         response = self.transport.run(None, toTimeDeltaOrNone(timeout))
         if response is None: break
         # Do not send miscellaneous ActorSystemMessages to the caller
         # that it might not recognize.
         if response and not isInternalActorSystemMessage(response.message):
             return response.message
     return None
 def _runSends(self, timeout=None):
     numsends = 0
     endtime = ((datetime.now() +
                 toTimeDeltaOrNone(timeout)) if timeout else None)
     while not endtime or datetime.now() < endtime:
         while self._pendingSends:
             numsends += 1
             if self.procLimit and numsends > self.procLimit:
                 raise RuntimeError('Too many sends')
             self._realizeWakeups()
             self._runSingleSend(self._pendingSends.pop(0))
         if not endtime:
             return
         now = datetime.now()
         valid_wakeups = [(W - now) for W in self._wakeUps if W <= endtime]
         if not valid_wakeups:
             return
         import time
         time.sleep(max(0, timePeriodSeconds(min(valid_wakeups))))
         self._realizeWakeups()
示例#6
0
 def _runSends(self, timeout=None):
     numsends = 0
     endtime = ((datetime.now() + toTimeDeltaOrNone(timeout))
                if timeout else None)
     while not endtime or datetime.now() < endtime:
         while self._pendingSends:
             numsends += 1
             if self.procLimit and numsends > self.procLimit:
                 raise RuntimeError('Too many sends')
             self._realizeWakeups()
             self._runSingleSend(self._pendingSends.pop(0))
         if not endtime:
             return
         now = datetime.now()
         valid_wakeups = [(W-now) for W in self._wakeUps if W <= endtime]
         if not valid_wakeups:
             return
         import time
         time.sleep(max(0, timePeriodSeconds(min(valid_wakeups))))
         self._realizeWakeups()