Checked if gevent thread is patched to do the right import
This commit is contained in:
parent
7a1ed64985
commit
1a2b404076
1 changed files with 12 additions and 1 deletions
|
@ -18,7 +18,18 @@ from sleekxmpp.util.misc_ops import bytes, unicode, hashes, hash, \
|
|||
# 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:
|
||||
|
|
Loading…
Reference in a new issue