Skip to content

Commit da47ebe

Browse files
committed
Skip gevent for python>=3.14
1 parent 6bdf3b3 commit da47ebe

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

bin/dramatiq-gevent

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
#!python
2+
import sys
3+
4+
if sys.version_info >= (3, 14):
5+
sys.stderr.write("error: gevent is not supported on Python 3.14 and later.")
6+
sys.exit(1)
7+
28
try:
3-
from gevent import monkey; monkey.patch_all() # noqa
9+
from gevent import monkey
10+
11+
monkey.patch_all() # noqa
412
except ImportError:
5-
import sys
613
sys.stderr.write("error: gevent is missing. Run `pip install gevent`.")
714
sys.exit(1)
815

9-
import sys
10-
1116
from dramatiq.cli import main
1217

1318
if __name__ == "__main__":

dramatiq/threading.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242

4343
def is_gevent_active():
4444
"""Detect if gevent monkey patching is active."""
45+
if python_version >= ("3", "14"):
46+
return False
47+
4548
try:
4649
from gevent import monkey
4750
except ImportError: # pragma: no cover
@@ -74,7 +77,9 @@ def raise_thread_exception(thread_id, exception):
7477
_raise_thread_exception_cpython(thread_id, exception)
7578
else:
7679
message = "Setting thread exceptions (%s) is not supported for your current platform (%r)."
77-
exctype = (exception if inspect.isclass(exception) else type(exception)).__name__
80+
exctype = (
81+
exception if inspect.isclass(exception) else type(exception)
82+
).__name__
7883
logger.critical(message, exctype, current_platform)
7984

8085

@@ -84,7 +89,11 @@ def _raise_thread_exception_cpython(thread_id, exception):
8489
exception = ctypes.py_object(exception)
8590
count = ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, exception)
8691
if count == 0:
87-
logger.critical("Failed to set exception (%s) in thread %r.", exctype, thread_id.value)
92+
logger.critical(
93+
"Failed to set exception (%s) in thread %r.", exctype, thread_id.value
94+
)
8895
elif count > 1: # pragma: no cover
89-
logger.critical("Exception (%s) was set in multiple threads. Undoing...", exctype)
96+
logger.critical(
97+
"Exception (%s) was set in multiple threads. Undoing...", exctype
98+
)
9099
ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, ctypes.c_long(0))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def rel(*xs):
4343

4444
extra_dependencies = {
4545
"gevent": [
46-
"gevent>=1.1",
46+
"gevent>=1.1; python_version < '3.14'",
4747
],
4848
"memcached": [
4949
"pylibmc>=1.5,<2.0",

0 commit comments

Comments
 (0)