Skip to content

Commit 3d64532

Browse files
authored
Revert Fix test failures commits (#1995)
1 parent 4cb7801 commit 3d64532

25 files changed

+2765
-640
lines changed

.evergreen/config.yml

Lines changed: 2655 additions & 92 deletions
Large diffs are not rendered by default.

.evergreen/scripts/generate_config.py

Lines changed: 67 additions & 480 deletions
Large diffs are not rendered by default.

pymongo/asynchronous/mongo_client.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"""
3333
from __future__ import annotations
3434

35-
import asyncio
3635
import contextlib
3736
import os
3837
import warnings
@@ -2037,8 +2036,6 @@ async def _process_kill_cursors(self) -> None:
20372036
for address, cursor_id, conn_mgr in pinned_cursors:
20382037
try:
20392038
await self._cleanup_cursor_lock(cursor_id, address, conn_mgr, None, False)
2040-
except asyncio.CancelledError:
2041-
raise
20422039
except Exception as exc:
20432040
if isinstance(exc, InvalidOperation) and self._topology._closed:
20442041
# Raise the exception when client is closed so that it
@@ -2053,8 +2050,6 @@ async def _process_kill_cursors(self) -> None:
20532050
for address, cursor_ids in address_to_cursor_ids.items():
20542051
try:
20552052
await self._kill_cursors(cursor_ids, address, topology, session=None)
2056-
except asyncio.CancelledError:
2057-
raise
20582053
except Exception as exc:
20592054
if isinstance(exc, InvalidOperation) and self._topology._closed:
20602055
raise
@@ -2069,8 +2064,6 @@ async def _process_periodic_tasks(self) -> None:
20692064
try:
20702065
await self._process_kill_cursors()
20712066
await self._topology.update_pool()
2072-
except asyncio.CancelledError:
2073-
raise
20742067
except Exception as exc:
20752068
if isinstance(exc, InvalidOperation) and self._topology._closed:
20762069
return

pymongo/asynchronous/monitor.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from __future__ import annotations
1818

19-
import asyncio
2019
import atexit
2120
import logging
2221
import time
@@ -27,7 +26,7 @@
2726
from pymongo._csot import MovingMinimum
2827
from pymongo.errors import NetworkTimeout, NotPrimaryError, OperationFailure, _OperationCancelled
2928
from pymongo.hello import Hello
30-
from pymongo.lock import _async_create_lock
29+
from pymongo.lock import _create_lock
3130
from pymongo.logger import _SDAM_LOGGER, _debug_log, _SDAMStatusMessage
3231
from pymongo.periodic_executor import _shutdown_executors
3332
from pymongo.pool_options import _is_faas
@@ -277,7 +276,7 @@ async def _check_server(self) -> ServerDescription:
277276
await self._reset_connection()
278277
if isinstance(error, _OperationCancelled):
279278
raise
280-
await self._rtt_monitor.reset()
279+
self._rtt_monitor.reset()
281280
# Server type defaults to Unknown.
282281
return ServerDescription(address, error=error)
283282

@@ -316,9 +315,9 @@ async def _check_once(self) -> ServerDescription:
316315
self._cancel_context = conn.cancel_context
317316
response, round_trip_time = await self._check_with_socket(conn)
318317
if not response.awaitable:
319-
await self._rtt_monitor.add_sample(round_trip_time)
318+
self._rtt_monitor.add_sample(round_trip_time)
320319

321-
avg_rtt, min_rtt = await self._rtt_monitor.get()
320+
avg_rtt, min_rtt = self._rtt_monitor.get()
322321
sd = ServerDescription(address, response, avg_rtt, min_round_trip_time=min_rtt)
323322
if self._publish:
324323
assert self._listeners is not None
@@ -414,8 +413,6 @@ def _get_seedlist(self) -> Optional[list[tuple[str, Any]]]:
414413
if len(seedlist) == 0:
415414
# As per the spec: this should be treated as a failure.
416415
raise Exception
417-
except asyncio.CancelledError:
418-
raise
419416
except Exception:
420417
# As per the spec, upon encountering an error:
421418
# - An error must not be raised
@@ -444,28 +441,28 @@ def __init__(self, topology: Topology, topology_settings: TopologySettings, pool
444441
self._pool = pool
445442
self._moving_average = MovingAverage()
446443
self._moving_min = MovingMinimum()
447-
self._lock = _async_create_lock()
444+
self._lock = _create_lock()
448445

449446
async def close(self) -> None:
450447
self.gc_safe_close()
451448
# Increment the generation and maybe close the socket. If the executor
452449
# thread has the socket checked out, it will be closed when checked in.
453450
await self._pool.reset()
454451

455-
async def add_sample(self, sample: float) -> None:
452+
def add_sample(self, sample: float) -> None:
456453
"""Add a RTT sample."""
457-
async with self._lock:
454+
with self._lock:
458455
self._moving_average.add_sample(sample)
459456
self._moving_min.add_sample(sample)
460457

461-
async def get(self) -> tuple[Optional[float], float]:
458+
def get(self) -> tuple[Optional[float], float]:
462459
"""Get the calculated average, or None if no samples yet and the min."""
463-
async with self._lock:
460+
with self._lock:
464461
return self._moving_average.get(), self._moving_min.get()
465462

466-
async def reset(self) -> None:
463+
def reset(self) -> None:
467464
"""Reset the average RTT."""
468-
async with self._lock:
465+
with self._lock:
469466
self._moving_average.reset()
470467
self._moving_min.reset()
471468

@@ -475,12 +472,10 @@ async def _run(self) -> None:
475472
# heartbeat protocol (MongoDB 4.4+).
476473
# XXX: Skip check if the server is unknown?
477474
rtt = await self._ping()
478-
await self.add_sample(rtt)
475+
self.add_sample(rtt)
479476
except ReferenceError:
480477
# Topology was garbage-collected.
481478
await self.close()
482-
except asyncio.CancelledError:
483-
raise
484479
except Exception:
485480
await self._pool.reset()
486481

pymongo/asynchronous/pool.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,6 @@ def _close_conn(self) -> None:
704704
# shutdown.
705705
try:
706706
self.conn.close()
707-
except asyncio.CancelledError:
708-
raise
709707
except Exception: # noqa: S110
710708
pass
711709

pymongo/network_layer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ async def async_receive_data(
271271
)
272272
for task in pending:
273273
task.cancel()
274-
if pending:
275-
await asyncio.wait(pending)
274+
await asyncio.wait(pending)
276275
if len(done) == 0:
277276
raise socket.timeout("timed out")
278277
if read_task in done:

pymongo/synchronous/mongo_client.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"""
3333
from __future__ import annotations
3434

35-
import asyncio
3635
import contextlib
3736
import os
3837
import warnings
@@ -2031,8 +2030,6 @@ def _process_kill_cursors(self) -> None:
20312030
for address, cursor_id, conn_mgr in pinned_cursors:
20322031
try:
20332032
self._cleanup_cursor_lock(cursor_id, address, conn_mgr, None, False)
2034-
except asyncio.CancelledError:
2035-
raise
20362033
except Exception as exc:
20372034
if isinstance(exc, InvalidOperation) and self._topology._closed:
20382035
# Raise the exception when client is closed so that it
@@ -2047,8 +2044,6 @@ def _process_kill_cursors(self) -> None:
20472044
for address, cursor_ids in address_to_cursor_ids.items():
20482045
try:
20492046
self._kill_cursors(cursor_ids, address, topology, session=None)
2050-
except asyncio.CancelledError:
2051-
raise
20522047
except Exception as exc:
20532048
if isinstance(exc, InvalidOperation) and self._topology._closed:
20542049
raise
@@ -2063,8 +2058,6 @@ def _process_periodic_tasks(self) -> None:
20632058
try:
20642059
self._process_kill_cursors()
20652060
self._topology.update_pool()
2066-
except asyncio.CancelledError:
2067-
raise
20682061
except Exception as exc:
20692062
if isinstance(exc, InvalidOperation) and self._topology._closed:
20702063
return

pymongo/synchronous/monitor.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from __future__ import annotations
1818

19-
import asyncio
2019
import atexit
2120
import logging
2221
import time
@@ -414,8 +413,6 @@ def _get_seedlist(self) -> Optional[list[tuple[str, Any]]]:
414413
if len(seedlist) == 0:
415414
# As per the spec: this should be treated as a failure.
416415
raise Exception
417-
except asyncio.CancelledError:
418-
raise
419416
except Exception:
420417
# As per the spec, upon encountering an error:
421418
# - An error must not be raised
@@ -479,8 +476,6 @@ def _run(self) -> None:
479476
except ReferenceError:
480477
# Topology was garbage-collected.
481478
self.close()
482-
except asyncio.CancelledError:
483-
raise
484479
except Exception:
485480
self._pool.reset()
486481

pymongo/synchronous/pool.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,6 @@ def _close_conn(self) -> None:
702702
# shutdown.
703703
try:
704704
self.conn.close()
705-
except asyncio.CancelledError:
706-
raise
707705
except Exception: # noqa: S110
708706
pass
709707

test/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import asyncio
1919
import gc
20-
import logging
2120
import multiprocessing
2221
import os
2322
import signal
@@ -26,7 +25,6 @@
2625
import sys
2726
import threading
2827
import time
29-
import traceback
3028
import unittest
3129
import warnings
3230
from asyncio import iscoroutinefunction
@@ -193,8 +191,6 @@ def _connect(self, host, port, **kwargs):
193191
client.close()
194192

195193
def _init_client(self):
196-
self.mongoses = []
197-
self.connection_attempts = []
198194
self.client = self._connect(host, port)
199195
if self.client is not None:
200196
# Return early when connected to dataLake as mongohoused does not

0 commit comments

Comments
 (0)