diff options
author | Joshua Harlow <harlowja@gmail.com> | 2014-08-31 14:34:51 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2014-08-31 14:34:51 -0700 |
commit | 0ea5438f532d8285c7bb68da23fc9772c6bf55f0 (patch) | |
tree | b223caeb58f5ad17ed3ccb4f8c120c47f76d30c5 | |
parent | 8979f4463ba3dec612fea35f0262dda746d10ffb (diff) | |
download | zake-0ea5438f532d8285c7bb68da23fc9772c6bf55f0.tar.gz |
Just take the wait method from 2.7
This logic will also function correctly
on 2.6 and it ensures we do things in a safe
manner.
-rw-r--r-- | zake/tests/test_client.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/zake/tests/test_client.py b/zake/tests/test_client.py index f97acc3..ce74063 100644 --- a/zake/tests/test_client.py +++ b/zake/tests/test_client.py @@ -33,16 +33,16 @@ from zake import test WAIT_TIME = 60 -if sys.version_info[0:2] <= (2, 6): +if sys.version_info[0:2] == (2, 6): class Event(threading._Event): def wait(self, timeout=None): - super(Event, self).wait(timeout) - # This isn't perfect since another thread could have changed it - # after the above wait, but this is fine for our usage... - if timeout is not None: - return self.is_set() - else: - return True + self.__cond.acquire() + try: + if not self.__flag: + self.__cond.wait(timeout) + return self.__flag + finally: + self.__cond.release() else: Event = threading.Event |