diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2009-10-06 16:19:30 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2009-10-06 16:19:30 +0000 |
| commit | 5077b5b804a418a5f553b8067c1fb6d65082f48a (patch) | |
| tree | 882f7f54daf7ac15b2dd293705d555ee62656bdc | |
| parent | 33835078ba46fc5937dcdf1a713dd187f8628bf5 (diff) | |
| download | qpid-python-5077b5b804a418a5f553b8067c1fb6d65082f48a.tar.gz | |
compatibility changes for python 2.3
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@822332 13f79535-47bb-0310-9956-ffa450edef68
| -rw-r--r-- | python/qpid/compat.py | 11 | ||||
| -rw-r--r-- | python/qpid/selector.py | 7 |
2 files changed, 12 insertions, 6 deletions
diff --git a/python/qpid/compat.py b/python/qpid/compat.py index 49273193df..53ab757e89 100644 --- a/python/qpid/compat.py +++ b/python/qpid/compat.py @@ -17,6 +17,8 @@ # under the License. # +import sys + try: set = set except NameError: @@ -30,6 +32,13 @@ except ImportError: try: from traceback import format_exc except ImportError: - import sys, traceback + import traceback def format_exc(): return "".join(traceback.format_exception(*sys.exc_info())) + +if tuple(sys.version_info[0:2]) < (2, 4): + from select import select as old_select + def select(rlist, wlist, xlist, timeout=None): + return old_select(list(rlist), list(wlist), list(xlist), timeout) +else: + from select import select diff --git a/python/qpid/selector.py b/python/qpid/selector.py index 05b8d3a203..710f8f0689 100644 --- a/python/qpid/selector.py +++ b/python/qpid/selector.py @@ -17,7 +17,7 @@ # under the License. # import atexit, os, time -from select import select +from compat import select, set from threading import Thread, Lock class Acceptor: @@ -84,10 +84,7 @@ class Selector: self.thread = None def wakeup(self): - while True: - select([], [self.wakeup_fd], []) - if os.write(self.wakeup_fd, "\0") > 0: - break + os.write(self.wakeup_fd, "\0") def register(self, selectable): self.selectables.add(selectable) |
