Skip to content

Commit

Permalink
Checked if gevent thread is patched to do the right import
Browse files Browse the repository at this point in the history
  • Loading branch information
pvicente committed Nov 12, 2012
1 parent 7a1ed64 commit 1a2b404
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sleekxmpp/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@
# Standardize import of Queue class:

import sys
if 'gevent' in sys.modules:

def _gevent_threads_enabled():
if not 'gevent' in sys.modules:
return False
try:
from gevent import thread as green_thread
thread = __import__('thread')
return thread.LockType is green_thread.LockType
except ImportError:
return False

if _gevent_threads_enabled():
import gevent.queue as queue
Queue = queue.JoinableQueue
else:
Expand Down

0 comments on commit 1a2b404

Please sign in to comment.