summaryrefslogtreecommitdiff
path: root/python/qpid/messaging
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2010-04-09 13:52:49 +0000
committerRafael H. Schloming <rhs@apache.org>2010-04-09 13:52:49 +0000
commit9487cef6ecb398e03b436bb641ca5961da819147 (patch)
tree186f195993e807caabcc1bd08f80bdea6287cb1d /python/qpid/messaging
parent4231f0f05a3b25fc1e2981934e8e75adad62971b (diff)
downloadqpid-python-9487cef6ecb398e03b436bb641ca5961da819147.tar.gz
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
Diffstat (limited to 'python/qpid/messaging')
-rw-r--r--python/qpid/messaging/endpoints.py20
1 files changed, 17 insertions, 3 deletions
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
@@ -726,6 +726,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):
"""
Send a message. If the object passed in is of type L{unicode},
@@ -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.