From 9487cef6ecb398e03b436bb641ca5961da819147 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Fri, 9 Apr 2010 13:52:49 +0000 Subject: Sender.pending() -> Sender.unsettled(); Receiver.pending() -> Receiver.available(); added Sender.available() and Receiver.unsettled() git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@932415 13f79535-47bb-0310-9956-ffa450edef68 --- python/qpid/messaging/endpoints.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'python/qpid/messaging') diff --git a/python/qpid/messaging/endpoints.py b/python/qpid/messaging/endpoints.py index be657173fe..3f5cf3b9bd 100644 --- a/python/qpid/messaging/endpoints.py +++ b/python/qpid/messaging/endpoints.py @@ -717,7 +717,7 @@ class Sender: return result @synchronized - def pending(self): + def unsettled(self): """ Returns the number of messages awaiting acknowledgment. @rtype: int @@ -725,6 +725,13 @@ class Sender: """ return self.queued - self.acked + @synchronized + def available(self): + if self.capacity is UNLIMITED: + return UNLIMITED + else: + return self.capacity - self.unsettled() + @synchronized def send(self, object, sync=True, timeout=None): """ @@ -763,7 +770,7 @@ class Sender: if self.capacity is not UNLIMITED: if self.capacity <= 0: raise InsufficientCapacity("capacity = %s" % self.capacity) - if not self._ewait(lambda: self.pending() < self.capacity, timeout=timeout): + if not self._ewait(self.available, timeout=timeout): raise InsufficientCapacity("capacity = %s" % self.capacity) # XXX: what if we send the same message to multiple senders? @@ -853,7 +860,14 @@ class Receiver(object): return result @synchronized - def pending(self): + def unsettled(self): + """ + Returns the number of acknowledged messages awaiting confirmation. + """ + return len([m for m in self.acked if m._receiver is self]) + + @synchronized + def available(self): """ Returns the number of messages available to be fetched by the application. -- cgit v1.2.1