def _cleanDeliveries(self, conn): link = proton.pn_link_head(conn, (proton.PN_LOCAL_ACTIVE)) while link: d = proton.pn_unsettled_head(link) while d: _next = proton.pn_unsettled_next(d) disp = proton.pn_delivery_remote_state(d) age = time.time() - proton.pn_delivery_get_context(d) self.log.debug("Checking delivery") if disp and disp != proton.PN_ACCEPTED: self.log.warn("Message was not accepted by remote end") if disp and proton.pn_delivery_settled(d): self.log.debug("Message settled by remote end") proton.pn_delivery_settle(d) elif age > self._deliveryTimeout: self.log.warn("Delivary not settled by remote host") proton.pn_delivery_settle(d) elif proton.pn_link_state(link) & proton.PN_REMOTE_CLOSED: self.log.warn("Link closed before settling message") proton.pn_delivery_settle(d) d = _next link = proton.pn_link_next(link, (proton.PN_LOCAL_ACTIVE))
def delivery_iter(link): d = proton.pn_unsettled_head(link) while d: yield d d = proton.pn_unsettled_next(d)