Exemple #1
0
 def dispatch(self, document):
     """
     Dispatch received request.
     The serial number of failed requests is added to the blacklist
     help prevent dispatching both failure and success replies.
     :param document: The received document.
     :type document: Document
     """
     try:
         reply = Reply(document)
         if document.sn in self.blacklist:
             # ignored
             return
         if reply.accepted():
             reply = Accepted(document)
             reply.notify(self.listener)
             return
         if reply.rejected():
             reply = Rejected(document)
             reply.notify(self.listener)
             return
         if reply.started():
             reply = Started(document)
             reply.notify(self.listener)
             return
         if reply.progress():
             reply = Progress(document)
             reply.notify(self.listener)
             return
         if reply.succeeded():
             self.blacklist.add(document.sn)
             reply = Succeeded(document)
             reply.notify(self.listener)
             return
         if reply.failed():
             self.blacklist.add(document.sn)
             reply = Failed(document)
             reply.notify(self.listener)
             return
     except Exception:
         log.exception(document)
Exemple #2
0
 def dispatch(self, document):
     """
     Dispatch received request.
     The serial number of failed requests is added to the blacklist
     help prevent dispatching both failure and success replies.
     :param document: The received document.
     :type document: Document
     """
     try:
         reply = Reply(document)
         if document.sn in self.blacklist:
             # ignored
             return
         if reply.accepted():
             reply = Accepted(document)
             reply.notify(self.listener)
             return
         if reply.rejected():
             reply = Rejected(document)
             reply.notify(self.listener)
             return
         if reply.started():
             reply = Started(document)
             reply.notify(self.listener)
             return
         if reply.progress():
             reply = Progress(document)
             reply.notify(self.listener)
             return
         if reply.succeeded():
             self.blacklist.add(document.sn)
             reply = Succeeded(document)
             reply.notify(self.listener)
             return
         if reply.failed():
             self.blacklist.add(document.sn)
             reply = Failed(document)
             reply.notify(self.listener)
             return
     except Exception:
         log.exception(document)