diff options
| author | Gordon Sim <gsim@apache.org> | 2007-07-26 16:08:40 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2007-07-26 16:08:40 +0000 |
| commit | 80f9f9b602a443d056f8bf3aeff24c1fff2feed6 (patch) | |
| tree | ebf252d7f019cc3242cb43574896ddb6db04f7bc /python/qpid | |
| parent | 233cc9184c758702d8fa4a83d1bf8ec7dc0b3474 (diff) | |
| download | qpid-python-80f9f9b602a443d056f8bf3aeff24c1fff2feed6.tar.gz | |
Changed use of Event to directly use Condition to workaround problems on other platforms (where Event.wait() returned immediately after a set()/clear()).
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@559869 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid')
| -rw-r--r-- | python/qpid/peer.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/python/qpid/peer.py b/python/qpid/peer.py index d7ae85e345..3927f20667 100644 --- a/python/qpid/peer.py +++ b/python/qpid/peer.py @@ -351,8 +351,8 @@ class Future: class ExecutionCompletion: def __init__(self): - self.completed = threading.Event() - self.sequence = Sequence(0) + self.condition = threading.Condition() + self.sequence = Sequence(1) self.command_id = 0 self.mark = 0 @@ -362,19 +362,27 @@ class ExecutionCompletion: self.command_id = self.sequence.next() def close(self): - self.completed.set() + self.condition.acquire() + try: + self.condition.notifyAll() + finally: + self.condition.release() def complete(self, mark): - self.mark = mark - self.completed.set() - self.completed.clear() + self.condition.acquire() + try: + self.mark = mark + self.condition.notifyAll() + finally: + self.condition.release() def wait(self, point_of_interest=-1, timeout=None): - """ - todo: really want to allow different threads to call this with - different points of interest on the same channel, this is a quick - hack for now - """ if point_of_interest == -1: point_of_interest = self.command_id - self.completed.wait(timeout) + self.condition.acquire() + try: + if point_of_interest > self.mark: + self.condition.wait(timeout) + finally: + self.condition.release() + #todo: retry until timed out or closed return point_of_interest <= self.mark |
