From 2a4e4352282e393e2843bc8d4c5847d7351ef34c Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 24 Oct 2012 01:20:23 -0700 Subject: Enable gevent support. Closes issues #166 and #167 Thanks to @pvicent, @chason, and @gabriel-samfira --- sleekxmpp/util/__init__.py | 16 ++++++++++------ sleekxmpp/xmlstream/filesocket.py | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sleekxmpp/util/__init__.py b/sleekxmpp/util/__init__.py index 7637dda0..1e4af02d 100644 --- a/sleekxmpp/util/__init__.py +++ b/sleekxmpp/util/__init__.py @@ -17,11 +17,15 @@ from sleekxmpp.util.misc_ops import bytes, unicode, hashes, hash, \ # ===================================================================== # Standardize import of Queue class: -try: - import queue -except ImportError: - import Queue as queue +import sys +if 'gevent' in sys.modules: + import gevent.queue as queue + Queue = queue.JoinableQueue +else: + try: + import queue + except ImportError: + import Queue as queue + Queue = queue.Queue - -Queue = queue.Queue QueueEmpty = queue.Empty diff --git a/sleekxmpp/xmlstream/filesocket.py b/sleekxmpp/xmlstream/filesocket.py index 56554c73..d4537998 100644 --- a/sleekxmpp/xmlstream/filesocket.py +++ b/sleekxmpp/xmlstream/filesocket.py @@ -34,7 +34,7 @@ class FileSocket(_fileobject): return data -class Socket26(socket._socketobject): +class Socket26(socket.socket): """A custom socket implementation that uses our own FileSocket class to work around issues in Python 2.6 when using sockets as files. -- cgit v1.2.3