def deliver(self):
        deferred = []
        srg = self.routes.get
        empty = set()
        sorter = op.attrgetter("reschedule_at")
        while True:
            wait = (1.0 if not deferred else 
                    deferred[-1].remaining)
            r, next = first(waits=[self.incoming, 
                self.table_changes], sleep=wait)
            if r == self.incoming:
                if next.rqueue:
                    self.rpc_waits[next.id] = next.rqueue

                hosts = srg(next.target, empty)
                potentials = next.hosts_tried - hosts
                if not potentials:
                    next.reschedule()
                    deferred.append(next)
                else:
                    host = choice(list(potentials))
                    next.hosts_tried.add(host)
                    self.pending[next.id] = next
                    self.host_specific_send(host, next.env,
                            MESSAGE_OUT, 
                            partial(self.retry, next.id))

            deferred.sort(key=sorter, reverse=True)
            t = time()
            while deferred and deferred[-1].due(t):
                i = deferred.pop()
                if not i.expired(t):
                    self.incoming.put(i)
dataset/ETHPy150Open dieseldev/diesel/diesel/convoy/__init__.py/Convoy.deliver/swapped operands of `-`