Checked if gevent thread is patched to do the right import

This commit is contained in:
Pedro Vicente 2012-11-12 13:28:20 +01:00
parent 7a1ed64985
commit 1a2b404076

View file

@ -18,7 +18,18 @@ from sleekxmpp.util.misc_ops import bytes, unicode, hashes, hash, \
# Standardize import of Queue class: # Standardize import of Queue class:
import sys 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 import gevent.queue as queue
Queue = queue.JoinableQueue Queue = queue.JoinableQueue
else: else: