diff options
author | Rafael H. Schloming <rhs@apache.org> | 2007-05-30 22:11:24 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2007-05-30 22:11:24 +0000 |
commit | 88859adc0c87a2261d39343daab2290dd6b3eb0e (patch) | |
tree | 8a875fa57eec7c0e6f751df6a03a40fe6a685bb0 /python/qpid/queue.py | |
parent | 0fc923acb5e8746c59e0d3132fa330bdf53d374f (diff) | |
download | qpid-python-88859adc0c87a2261d39343daab2290dd6b3eb0e.tar.gz |
added listener support to queues, also added support for non version specific tests
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@542955 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/queue.py')
-rw-r--r-- | python/qpid/queue.py | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/python/qpid/queue.py b/python/qpid/queue.py index 5438b328ab..af0565b6cc 100644 --- a/python/qpid/queue.py +++ b/python/qpid/queue.py @@ -31,15 +31,29 @@ class Queue(BaseQueue): END = object() + def __init__(self, *args, **kwargs): + BaseQueue.__init__(self, *args, **kwargs) + self._real_put = self.put + self.listener = self._real_put + def close(self): self.put(Queue.END) def get(self, block = True, timeout = None): - result = BaseQueue.get(self, block, timeout) - if result == Queue.END: - # this guarantees that any other waiting threads or any future - # calls to get will also result in a Closed exception - self.put(Queue.END) - raise Closed() - else: - return result + self.put = self._real_put + try: + result = BaseQueue.get(self, block, timeout) + if result == Queue.END: + # this guarantees that any other waiting threads or any future + # calls to get will also result in a Closed exception + self.put(Queue.END) + raise Closed() + else: + return result + finally: + self.put = self.listener + pass + + def listen(self, listener): + self.listener = listener + self.put = self.listener |