diff --git a/cassandra/cluster.py b/cassandra/cluster.py index 45fc62a7c0..fd73803eb8 100644 --- a/cassandra/cluster.py +++ b/cassandra/cluster.py @@ -117,10 +117,9 @@ def _is_gevent_monkey_patched(): if 'gevent.monkey' not in sys.modules: return False try: - import eventlet.patcher - return eventlet.patcher.is_monkey_patched('socket') - # Another case related to PYTHON-1364 - except AttributeError: + import gevent.socket + return socket.socket is gevent.socket.socket # Another case related to PYTHON-1364 + except (AttributeError, ImportError): return False def _try_gevent_import(): diff --git a/scripts/run_integration_test.sh b/scripts/run_integration_test.sh index 017ebcf5b4..2944e045db 100755 --- a/scripts/run_integration_test.sh +++ b/scripts/run_integration_test.sh @@ -17,7 +17,8 @@ fi python3 -m venv .test-venv source .test-venv/bin/activate -pip install -U pip wheel setuptools +pip install --upgrade pip +pip install -U wheel setuptools # install driver wheel pip install --ignore-installed -r test-requirements.txt pytest diff --git a/tests/__init__.py b/tests/__init__.py index 56a9759445..0966d5041e 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -61,13 +61,10 @@ def is_monkey_patched(): thread_pool_executor_class = ThreadPoolExecutor if "gevent" in EVENT_LOOP_MANAGER: - try: - import gevent.monkey - gevent.monkey.patch_all() - from cassandra.io.geventreactor import GeventConnection - connection_class = GeventConnection - except ImportError: - connection_class = None + import gevent.monkey + gevent.monkey.patch_all() + from cassandra.io.geventreactor import GeventConnection + connection_class = GeventConnection elif "eventlet" in EVENT_LOOP_MANAGER: from eventlet import monkey_patch monkey_patch() @@ -90,6 +87,9 @@ def is_monkey_patched(): elif "asyncio" in EVENT_LOOP_MANAGER: from cassandra.io.asyncioreactor import AsyncioConnection connection_class = AsyncioConnection +elif "libev" in EVENT_LOOP_MANAGER: + from cassandra.io.libevreactor import LibevConnection + connection_class = LibevConnection else: log.debug("Using default event loop (libev)") try: