pyngus/link.py
def _process_delivery(self, pn_delivery):
        """Check if the delivery can be processed."""
        if pn_delivery.tag in self._send_requests:
            if pn_delivery.settled or pn_delivery.remote_state:
                # remote has reached a 'terminal state'
                outcome = pn_delivery.remote_state
                state = SenderLink._DISPOSITION_STATE_MAP.get(outcome,
                                                              self.UNKNOWN)
                pn_disposition = pn_delivery.remote
                info = {}
                if state == SenderLink.REJECTED:
                    if pn_disposition.condition:
                        info["condition"] = pn_disposition.condition
                elif state == SenderLink.MODIFIED:
                    info["delivery-failed"] = pn_disposition.failed
                    info["undeliverable-here"] = pn_disposition.undeliverable
                    annotations = pn_disposition.annotations
                    if annotations:
                        info["message-annotations"] = annotations
                send_req = self._send_requests.pop(pn_delivery.tag)
                send_req.destroy(state, info)
                pn_delivery.settle()
            elif pn_delivery.writable:
                # we can now send on this delivery
                if self._pending_sends:
                    tag = self._pending_sends.popleft()
                    send_req = self._send_requests[tag]
                    self._write_msg(pn_delivery, send_req)
        else:
            # tag no longer valid, expired or canceled send?
            LOG.debug("Delivery ignored, tag=%s", str(pn_delivery.tag))
            pn_delivery.settle()
def _process_delivery(self, pn_delivery):
        """Check if the delivery can be processed."""
        if pn_delivery.tag in self._send_requests:
            if pn_delivery.settled or pn_delivery.remote_state:
                # remote has reached a 'terminal state'
                outcome = pn_delivery.remote_state
                state = SenderLink._DISPOSITION_STATE_MAP.get(outcome,
                                                              self.UNKNOWN)
                pn_disposition = pn_delivery.remote
                info = {}
                if state == SenderLink.REJECTED:
                    if pn_disposition.condition:
                        info["condition"] = pn_disposition.condition
                elif state == SenderLink.MODIFIED:
                    info["delivery-failed"] = pn_disposition.failed
                    info["undeliverable-here"] = pn_disposition.undeliverable
                    annotations = pn_disposition.annotations
                    if annotations:
                        info["message-annotations"] = annotations
                send_req = self._send_requests.pop(pn_delivery.tag)
                send_req.destroy(state, info)
                pn_delivery.settle()
            elif pn_delivery.writable:
                # we can now send on this delivery
                if self._pending_sends:
                    tag = self._pending_sends.popleft()
                    send_req = self._send_requests[tag]
                    self._write_msg(pn_delivery, send_req)
        else:
            # tag no longer valid, expired or canceled send?
            LOG.debug("Delivery ignored, tag=%s", str(pn_delivery.tag))
            pn_delivery.settle()
def _process_delivery ( self , pn_delivery ) : if pn_delivery . tag in self . _send_requests : if pn_delivery . settled or pn_delivery . remote_state : # remote has reached a 'terminal state' outcome = pn_delivery . remote_state state = SenderLink . _DISPOSITION_STATE_MAP . get ( outcome , self . UNKNOWN ) pn_disposition = pn_delivery . remote info = { } if state == SenderLink . REJECTED : if pn_disposition . condition : info [ "condition" ] = pn_disposition . condition elif state == SenderLink . MODIFIED : info [ "delivery-failed" ] = pn_disposition . failed info [ "undeliverable-here" ] = pn_disposition . undeliverable annotations = pn_disposition . annotations if annotations : info [ "message-annotations" ] = annotations send_req = self . _send_requests . pop ( pn_delivery . tag ) send_req . destroy ( state , info ) pn_delivery . settle ( ) elif pn_delivery . writable : # we can now send on this delivery if self . _pending_sends : tag = self . _pending_sends . popleft ( ) send_req = self . _send_requests [ tag ] self . _write_msg ( pn_delivery , send_req ) else : # tag no longer valid, expired or canceled send? LOG . debug ( "Delivery ignored, tag=%s" , str ( pn_delivery . tag ) ) pn_delivery . settle ( )
Check if the delivery can be processed.
Check if the delivery can be processed .