Skip to content

Commit 1556e92

Browse files
committed
remove eventlet and dnspython 1.0 support
1 parent b4967b8 commit 1556e92

File tree

12 files changed

+14
-55
lines changed

12 files changed

+14
-55
lines changed

.evergreen/scripts/run_tests.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,12 @@ def handle_perf(start_time: datetime):
4646

4747

4848
def handle_green_framework() -> None:
49-
if GREEN_FRAMEWORK == "eventlet":
50-
import eventlet
51-
52-
# https://github.com/eventlet/eventlet/issues/401
53-
eventlet.sleep()
54-
eventlet.monkey_patch()
55-
elif GREEN_FRAMEWORK == "gevent":
49+
if GREEN_FRAMEWORK == "gevent":
5650
from gevent import monkey
5751

5852
monkey.patch_all()
53+
else:
54+
raise ValueError(f"Unsupported green framework type: {GREEN_FRAMEWORK}")
5955

6056
# Never run async tests with a framework.
6157
if len(TEST_ARGS) <= 1:

.evergreen/scripts/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def get_test_options(
106106
parser.add_argument(
107107
"--green-framework",
108108
nargs=1,
109-
choices=["eventlet", "gevent"],
109+
choices=["gevent"],
110110
help="Optional green framework to test against.",
111111
)
112112
parser.add_argument(

pymongo/asynchronous/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ async def _raise_connection_failure(self, error: BaseException) -> NoReturn:
629629
# signals and throws KeyboardInterrupt into the current frame on the
630630
# main thread.
631631
#
632-
# But in Gevent and Eventlet, the polling mechanism (epoll, kqueue,
632+
# But in Gevent the polling mechanism (epoll, kqueue,
633633
# ..) is called in Python code, which experiences the signal as a
634634
# KeyboardInterrupt from the start, rather than as an initial
635635
# socket.error, so we catch that, close the socket, and reraise it.

pymongo/asynchronous/srv_resolver.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,15 @@ def maybe_decode(text: Union[str, bytes]) -> str:
4545
return text
4646

4747

48-
# PYTHON-2667 Lazily call dns.resolver methods for compatibility with eventlet.
4948
async def _resolve(*args: Any, **kwargs: Any) -> resolver.Answer:
5049
if _IS_SYNC:
5150
from dns import resolver
5251

53-
if hasattr(resolver, "resolve"):
54-
# dnspython >= 2
55-
return resolver.resolve(*args, **kwargs)
56-
# dnspython 1.X
57-
return resolver.query(*args, **kwargs)
52+
return resolver.resolve(*args, **kwargs)
5853
else:
5954
from dns import asyncresolver
6055

61-
if hasattr(asyncresolver, "resolve"):
62-
# dnspython >= 2
63-
return await asyncresolver.resolve(*args, **kwargs) # type:ignore[return-value]
64-
raise ConfigurationError(
65-
"Upgrade to dnspython version >= 2.0 to use AsyncMongoClient with mongodb+srv:// connections."
66-
)
56+
return await asyncresolver.resolve(*args, **kwargs) # type:ignore[return-value]
6757

6858

6959
_INVALID_HOST_MSG = (

pymongo/pool_shared.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ def _raise_connection_failure(
139139
msg += format_timeout_details(timeout_details)
140140
if isinstance(error, socket.timeout):
141141
raise NetworkTimeout(msg) from error
142-
elif isinstance(error, SSLErrors) and "timed out" in str(error):
143-
# Eventlet does not distinguish TLS network timeouts from other
144-
# SSLErrors (https://github.com/eventlet/eventlet/issues/692).
145-
# Luckily, we can work around this limitation because the phrase
146-
# 'timed out' appears in all the timeout related SSLErrors raised.
147-
raise NetworkTimeout(msg) from error
148142
else:
149143
raise AutoReconnect(msg) from error
150144

pymongo/synchronous/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ def _raise_connection_failure(self, error: BaseException) -> NoReturn:
627627
# signals and throws KeyboardInterrupt into the current frame on the
628628
# main thread.
629629
#
630-
# But in Gevent and Eventlet, the polling mechanism (epoll, kqueue,
630+
# But in Gevent the polling mechanism (epoll, kqueue,
631631
# ..) is called in Python code, which experiences the signal as a
632632
# KeyboardInterrupt from the start, rather than as an initial
633633
# socket.error, so we catch that, close the socket, and reraise it.

pymongo/synchronous/srv_resolver.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,15 @@ def maybe_decode(text: Union[str, bytes]) -> str:
4545
return text
4646

4747

48-
# PYTHON-2667 Lazily call dns.resolver methods for compatibility with eventlet.
4948
def _resolve(*args: Any, **kwargs: Any) -> resolver.Answer:
5049
if _IS_SYNC:
5150
from dns import resolver
5251

53-
if hasattr(resolver, "resolve"):
54-
# dnspython >= 2
55-
return resolver.resolve(*args, **kwargs)
56-
# dnspython 1.X
57-
return resolver.query(*args, **kwargs)
52+
return resolver.resolve(*args, **kwargs)
5853
else:
5954
from dns import asyncresolver
6055

61-
if hasattr(asyncresolver, "resolve"):
62-
# dnspython >= 2
63-
return asyncresolver.resolve(*args, **kwargs) # type:ignore[return-value]
64-
raise ConfigurationError(
65-
"Upgrade to dnspython version >= 2.0 to use MongoClient with mongodb+srv:// connections."
66-
)
56+
return asyncresolver.resolve(*args, **kwargs) # type:ignore[return-value]
6757

6858

6959
_INVALID_HOST_MSG = (

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ dev = [
5252
doctest = ["sphinx"]
5353
pip = ["pip"]
5454
gevent = ["gevent"]
55-
eventlet = ["eventlet"]
5655
coverage = [
5756
"pytest-cov",
5857
"coverage>=5,<=7.5"
@@ -116,15 +115,12 @@ filterwarnings = [
116115
"module:.*WindowsSelectorEventLoopPolicy:DeprecationWarning",
117116
"module:.*et_event_loop_policy:DeprecationWarning",
118117
# TODO: Remove as part of PYTHON-3923.
119-
"module:unclosed <eventlet.green.ssl.GreenSSLSocket:ResourceWarning",
120118
"module:unclosed <socket.socket:ResourceWarning",
121119
"module:unclosed <ssl.SSLSocket:ResourceWarning",
122120
"module:unclosed <socket object:ResourceWarning",
123121
"module:unclosed transport:ResourceWarning",
124122
# pytest-asyncio known issue: https://github.com/pytest-dev/pytest-asyncio/issues/724
125123
"module:unclosed event loop:ResourceWarning",
126-
# https://github.com/eventlet/eventlet/issues/818
127-
"module:please use dns.resolver.Resolver.resolve:DeprecationWarning",
128124
# https://github.com/dateutil/dateutil/issues/1314
129125
"module:datetime.datetime.utc:DeprecationWarning",
130126
]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dnspython>=1.16.0,<3.0.0
1+
dnspython>=2.6.0,<3.0.0

test/asynchronous/test_encryption.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ async def test_use_after_close(self):
395395
)
396396
@unittest.skipIf(
397397
is_greenthread_patched(),
398-
"gevent and eventlet do not support POSIX-style forking.",
398+
"gevent does not support POSIX-style forking.",
399399
)
400400
@async_client_context.require_sync
401401
async def test_fork(self):

0 commit comments

Comments
 (0)