Skip to content

Commit 546976d

Browse files
committed
Revert "wip update tests"
This reverts commit d3a4958.
1 parent 76c4ee6 commit 546976d

File tree

7 files changed

+47
-278
lines changed

7 files changed

+47
-278
lines changed

pymongo/asynchronous/helpers.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,22 +172,18 @@ async def inner(self: Any, *args: Any, **kwargs: Any) -> Any:
172172
retry_policy = self._retry_policy
173173
attempt = 0
174174
while True:
175-
print("in retry overload", attempt, func, args, kwargs)
176175
try:
177176
res = await func(self, *args, **kwargs)
178177
await retry_policy.record_success(retry=attempt > 0)
179-
print("finished retry overload", attempt, func, args, kwargs)
180178
return res
181179
except PyMongoError as exc:
182180
if not exc.has_error_label("RetryableError"):
183-
print("retry overload no retryable overload", attempt, func, args, kwargs)
184181
raise
185182
attempt += 1
186183
delay = 0
187184
if exc.has_error_label("SystemOverloadedError"):
188185
delay = retry_policy.backoff(attempt)
189186
if not await retry_policy.should_retry(attempt, delay):
190-
print("bailing on the retry", attempt, func, args, kwargs)
191187
raise
192188

193189
# Implement exponential backoff on retry.

pymongo/asynchronous/pool.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,6 @@ def _handle_connection_error(self, error: BaseException, phase: str) -> None:
10411041
# If found, set backoff and add error labels.
10421042
if self.is_sdam or type(error) not in (AutoReconnect, NetworkTimeout):
10431043
return
1044-
print("handling connection error", id(self))
10451044
error._add_error_label("SystemOverloadedError")
10461045
error._add_error_label("RetryableError")
10471046
self.backoff()
@@ -1327,7 +1326,6 @@ async def _get_conn(
13271326
conn = None
13281327
incremented = False
13291328
emitted_event = False
1330-
13311329
try:
13321330
async with self.lock:
13331331
self.active_sockets += 1
@@ -1339,24 +1337,15 @@ async def _get_conn(
13391337
self._raise_if_not_ready(checkout_started_time, emit_event=False)
13401338
while not (self.conns or self._pending < self.max_connecting):
13411339
timeout = deadline - time.monotonic() if deadline else None
1342-
if self._backoff and (self._backoff_connection_time > time.monotonic()):
1343-
timeout = 0.01
13441340
if not await _async_cond_wait(self._max_connecting_cond, timeout):
1345-
# Check whether we should continue to wait for the backoff condition.
1346-
if self._backoff and deadline is None or deadline < time.monotonic():
1347-
print("looping?", id(self))
1348-
if self._backoff_connection_time > time.monotonic():
1349-
print("continue", id(self))
1350-
continue
1351-
print("break", id(self))
1352-
break
13531341
# Timed out, notify the next thread to ensure a
13541342
# timeout doesn't consume the condition.
13551343
if self.conns or self._pending < self.max_connecting:
13561344
self._max_connecting_cond.notify()
13571345
emitted_event = True
13581346
self._raise_wait_queue_timeout(checkout_started_time)
13591347
self._raise_if_not_ready(checkout_started_time, emit_event=False)
1348+
13601349
try:
13611350
conn = self.conns.popleft()
13621351
except IndexError:
@@ -1366,22 +1355,17 @@ async def _get_conn(
13661355
conn = None
13671356
continue
13681357
# See if we need to wait for the backoff period.
1369-
elif self._backoff and (self._backoff_connection_time > time.monotonic()):
1370-
print("wat", id(self))
1358+
elif self._backoff and (self._backoff_connection_time < time.monotonic()):
13711359
continue
13721360
else: # We need to create a new connection
1373-
print("trying a connection", id(self))
13741361
try:
13751362
conn = await self.connect(handler=handler)
13761363
finally:
1377-
print("finished trying a connection", id(self))
13781364
async with self._max_connecting_cond:
13791365
self._pending -= 1
13801366
self._max_connecting_cond.notify()
1381-
13821367
# Catch KeyboardInterrupt, CancelledError, etc. and cleanup.
1383-
except BaseException as e:
1384-
print("got an exception", e, id(self))
1368+
except BaseException:
13851369
if conn:
13861370
# We checked out a socket but authentication failed.
13871371
await conn.close_conn(ConnectionClosedReason.ERROR)
@@ -1409,12 +1393,9 @@ async def _get_conn(
14091393
error=ConnectionCheckOutFailedReason.CONN_ERROR,
14101394
durationMS=duration,
14111395
)
1412-
print("raising the exception", id(self))
14131396
raise
14141397

14151398
conn.active = True
1416-
if self._backoff:
1417-
print("finished get_conn", id(self))
14181399
return conn
14191400

14201401
async def checkin(self, conn: AsyncConnection) -> None:

pymongo/synchronous/helpers.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,22 +172,18 @@ def inner(self: Any, *args: Any, **kwargs: Any) -> Any:
172172
retry_policy = self._retry_policy
173173
attempt = 0
174174
while True:
175-
print("in retry overload", attempt, func, args, kwargs)
176175
try:
177176
res = func(self, *args, **kwargs)
178177
retry_policy.record_success(retry=attempt > 0)
179-
print("finished retry overload", attempt, func, args, kwargs)
180178
return res
181179
except PyMongoError as exc:
182180
if not exc.has_error_label("RetryableError"):
183-
print("retry overload no retryable overload", attempt, func, args, kwargs)
184181
raise
185182
attempt += 1
186183
delay = 0
187184
if exc.has_error_label("SystemOverloadedError"):
188185
delay = retry_policy.backoff(attempt)
189186
if not retry_policy.should_retry(attempt, delay):
190-
print("bailing on the retry", attempt, func, args, kwargs)
191187
raise
192188

193189
# Implement exponential backoff on retry.

pymongo/synchronous/pool.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,6 @@ def _handle_connection_error(self, error: BaseException, phase: str) -> None:
10371037
# If found, set backoff and add error labels.
10381038
if self.is_sdam or type(error) not in (AutoReconnect, NetworkTimeout):
10391039
return
1040-
print("handling connection error", id(self))
10411040
error._add_error_label("SystemOverloadedError")
10421041
error._add_error_label("RetryableError")
10431042
self.backoff()
@@ -1323,7 +1322,6 @@ def _get_conn(
13231322
conn = None
13241323
incremented = False
13251324
emitted_event = False
1326-
13271325
try:
13281326
with self.lock:
13291327
self.active_sockets += 1
@@ -1335,24 +1333,15 @@ def _get_conn(
13351333
self._raise_if_not_ready(checkout_started_time, emit_event=False)
13361334
while not (self.conns or self._pending < self.max_connecting):
13371335
timeout = deadline - time.monotonic() if deadline else None
1338-
if self._backoff and (self._backoff_connection_time > time.monotonic()):
1339-
timeout = 0.01
13401336
if not _cond_wait(self._max_connecting_cond, timeout):
1341-
# Check whether we should continue to wait for the backoff condition.
1342-
if self._backoff and deadline is None or deadline < time.monotonic():
1343-
print("looping?", id(self))
1344-
if self._backoff_connection_time > time.monotonic():
1345-
print("continue", id(self))
1346-
continue
1347-
print("break", id(self))
1348-
break
13491337
# Timed out, notify the next thread to ensure a
13501338
# timeout doesn't consume the condition.
13511339
if self.conns or self._pending < self.max_connecting:
13521340
self._max_connecting_cond.notify()
13531341
emitted_event = True
13541342
self._raise_wait_queue_timeout(checkout_started_time)
13551343
self._raise_if_not_ready(checkout_started_time, emit_event=False)
1344+
13561345
try:
13571346
conn = self.conns.popleft()
13581347
except IndexError:
@@ -1362,22 +1351,17 @@ def _get_conn(
13621351
conn = None
13631352
continue
13641353
# See if we need to wait for the backoff period.
1365-
elif self._backoff and (self._backoff_connection_time > time.monotonic()):
1366-
print("wat", id(self))
1354+
elif self._backoff and (self._backoff_connection_time < time.monotonic()):
13671355
continue
13681356
else: # We need to create a new connection
1369-
print("trying a connection", id(self))
13701357
try:
13711358
conn = self.connect(handler=handler)
13721359
finally:
1373-
print("finished trying a connection", id(self))
13741360
with self._max_connecting_cond:
13751361
self._pending -= 1
13761362
self._max_connecting_cond.notify()
1377-
13781363
# Catch KeyboardInterrupt, CancelledError, etc. and cleanup.
1379-
except BaseException as e:
1380-
print("got an exception", e, id(self))
1364+
except BaseException:
13811365
if conn:
13821366
# We checked out a socket but authentication failed.
13831367
conn.close_conn(ConnectionClosedReason.ERROR)
@@ -1405,12 +1389,9 @@ def _get_conn(
14051389
error=ConnectionCheckOutFailedReason.CONN_ERROR,
14061390
durationMS=duration,
14071391
)
1408-
print("raising the exception", id(self))
14091392
raise
14101393

14111394
conn.active = True
1412-
if self._backoff:
1413-
print("finished get_conn", id(self))
14141395
return conn
14151396

14161397
def checkin(self, conn: Connection) -> None:

requirements/test.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
pytest>=8.2
22
pytest-asyncio>=0.24.0
3-
pytest-timeout

test/discovery_and_monitoring/unified/auth-network-error-fail.json

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)