From 1a2b404076a04953e63b8bd120d70e237c185d44 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Date: Mon, 12 Nov 2012 13:28:20 +0100 Subject: Checked if gevent thread is patched to do the right import --- sleekxmpp/util/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sleekxmpp/util/__init__.py b/sleekxmpp/util/__init__.py index 1e4af02d..957a9335 100644 --- a/sleekxmpp/util/__init__.py +++ b/sleekxmpp/util/__init__.py @@ -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: -- cgit v1.2.3 From b0c50b7a59fbc18cb01158fc901013a63ed87b90 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Date: Mon, 12 Nov 2012 13:48:20 +0100 Subject: Added gevent as parameter to testall checking test suite with gevent enabled/disabled --- testall.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/testall.py b/testall.py index c9ad5448..2cb6f538 100755 --- a/testall.py +++ b/testall.py @@ -1,7 +1,11 @@ #!/usr/bin/env python -import os import sys +if len(sys.argv)>1 and sys.argv[1].lower() == 'gevent': + from gevent import monkey + monkey.patch_all() + +import os import logging import unittest import distutils.core @@ -57,7 +61,7 @@ class TestCommand(distutils.core.Command): if __name__ == '__main__': result = run_tests() - print("" % ( + print("" % ( "xmlns='http//andyet.net/protocol/tests'", result.testsRun, len(result.errors), - len(result.failures), result.wasSuccessful())) + len(result.failures), result.wasSuccessful(),'gevent' in sys.modules)) -- cgit v1.2.3