Skip to content

Commit 49302f9

Browse files
committed
AC + CP review
1 parent 30ccd77 commit 49302f9

4 files changed

Lines changed: 12 additions & 23 deletions

File tree

pymongo/logger.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class _ConnectionStatusMessage(str, enum.Enum):
4242
POOL_READY = "Connection pool ready"
4343
POOL_CLOSED = "Connection pool closed"
4444
POOL_CLEARED = "Connection pool cleared"
45-
POOL_BACKOFF = "Connection pool backoff"
4645

4746
CONN_CREATED = "Connection created"
4847
CONN_READY = "Connection ready"
@@ -89,7 +88,6 @@ class _SDAMStatusMessage(str, enum.Enum):
8988
_VERBOSE_CONNECTION_ERROR_REASONS = {
9089
ConnectionClosedReason.POOL_CLOSED: "Connection pool was closed",
9190
ConnectionCheckOutFailedReason.POOL_CLOSED: "Connection pool was closed",
92-
ConnectionClosedReason.POOL_BACKOFF: "Connection pool is in backoff",
9391
ConnectionClosedReason.STALE: "Connection pool was stale",
9492
ConnectionClosedReason.ERROR: "An error occurred while using the connection",
9593
ConnectionCheckOutFailedReason.CONN_ERROR: "An error occurred while trying to establish a new connection",

pymongo/monitoring.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,6 @@ class ConnectionClosedReason:
934934
POOL_CLOSED = "poolClosed"
935935
"""The pool was closed, making the connection no longer valid."""
936936

937-
POOL_BACKOFF = "poolBackoff"
938-
"""The pool is in backoff mode."""
939-
940937

941938
class ConnectionCheckOutFailedReason:
942939
"""An enum that defines values for `reason` on a

test/asynchronous/test_retryable_writes.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -657,13 +657,15 @@ def failed(event: CommandFailedEvent) -> None:
657657
return
658658
assert event.failure["code"] == 91
659659
self.configure_fail_point_sync(command_args_inner)
660+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
660661
listener.failed_events.append(event)
661662

662663
listener.failed = failed
663664

664665
client = await self.async_rs_client(retryWrites=True, event_listeners=[listener])
665666

666667
self.configure_fail_point_sync(command_args)
668+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
667669

668670
# Attempt an insertOne operation on any record for any database and collection.
669671
# Expect the insertOne to fail with a server error.
@@ -673,9 +675,6 @@ def failed(event: CommandFailedEvent) -> None:
673675
# Assert that the error code of the server error is 10107.
674676
assert exc.exception.errors["code"] == 10107 # type:ignore[call-overload]
675677

676-
# Disable the fail point.
677-
self.configure_fail_point_sync({}, off=True)
678-
679678
async def test_02_drivers_return_the_correct_error_when_receiving_only_errors_with_NoWritesPerformed(
680679
self
681680
) -> None:
@@ -711,13 +710,15 @@ def failed(event: CommandFailedEvent) -> None:
711710
# Configure the 10107 fail point command only if the the failed event is for the 91 error configured in step 2.
712711
assert event.failure["code"] == 91
713712
self.configure_fail_point_sync(command_args_inner)
713+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
714714
listener.failed_events.append(event)
715715

716716
listener.failed = failed
717717

718718
client = await self.async_rs_client(retryWrites=True, event_listeners=[listener])
719719

720720
self.configure_fail_point_sync(command_args)
721+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
721722

722723
# Attempt an insertOne operation on any record for any database and collection.
723724
# Expect the insertOne to fail with a server error.
@@ -727,9 +728,6 @@ def failed(event: CommandFailedEvent) -> None:
727728
# Assert that the error code of the server error is 91.
728729
assert exc.exception.errors["code"] == 91 # type:ignore[call-overload]
729730

730-
# Disable the fail point.
731-
self.configure_fail_point_sync({}, off=True)
732-
733731
async def test_03_drivers_return_the_correct_error_when_receiving_some_errors_with_NoWritesPerformed_and_some_without_NoWritesPerformed(
734732
self
735733
) -> None:
@@ -766,13 +764,15 @@ def failed(event: CommandFailedEvent) -> None:
766764
return
767765
assert event.failure["code"] == 91
768766
self.configure_fail_point_sync(command_args_inner)
767+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
769768
listener.failed_events.append(event)
770769

771770
listener.failed = failed
772771

773772
client = await self.async_rs_client(retryWrites=True, event_listeners=[listener])
774773

775774
self.configure_fail_point_sync(command_args)
775+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
776776

777777
# Attempt an insertOne operation on any record for any database and collection.
778778
# Expect the insertOne to fail with a server error.
@@ -784,9 +784,6 @@ def failed(event: CommandFailedEvent) -> None:
784784
# Assert that the error does not contain the error label `NoWritesPerformed`.
785785
assert "NoWritesPerformed" not in exc.exception.errors["errorLabels"]
786786

787-
# Disable the fail point.
788-
self.configure_fail_point_sync({}, off=True)
789-
790787

791788
if __name__ == "__main__":
792789
unittest.main()

test/test_retryable_writes.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -653,13 +653,15 @@ def failed(event: CommandFailedEvent) -> None:
653653
return
654654
assert event.failure["code"] == 91
655655
self.configure_fail_point_sync(command_args_inner)
656+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
656657
listener.failed_events.append(event)
657658

658659
listener.failed = failed
659660

660661
client = self.rs_client(retryWrites=True, event_listeners=[listener])
661662

662663
self.configure_fail_point_sync(command_args)
664+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
663665

664666
# Attempt an insertOne operation on any record for any database and collection.
665667
# Expect the insertOne to fail with a server error.
@@ -669,9 +671,6 @@ def failed(event: CommandFailedEvent) -> None:
669671
# Assert that the error code of the server error is 10107.
670672
assert exc.exception.errors["code"] == 10107 # type:ignore[call-overload]
671673

672-
# Disable the fail point.
673-
self.configure_fail_point_sync({}, off=True)
674-
675674
def test_02_drivers_return_the_correct_error_when_receiving_only_errors_with_NoWritesPerformed(
676675
self
677676
) -> None:
@@ -707,13 +706,15 @@ def failed(event: CommandFailedEvent) -> None:
707706
# Configure the 10107 fail point command only if the the failed event is for the 91 error configured in step 2.
708707
assert event.failure["code"] == 91
709708
self.configure_fail_point_sync(command_args_inner)
709+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
710710
listener.failed_events.append(event)
711711

712712
listener.failed = failed
713713

714714
client = self.rs_client(retryWrites=True, event_listeners=[listener])
715715

716716
self.configure_fail_point_sync(command_args)
717+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
717718

718719
# Attempt an insertOne operation on any record for any database and collection.
719720
# Expect the insertOne to fail with a server error.
@@ -723,9 +724,6 @@ def failed(event: CommandFailedEvent) -> None:
723724
# Assert that the error code of the server error is 91.
724725
assert exc.exception.errors["code"] == 91 # type:ignore[call-overload]
725726

726-
# Disable the fail point.
727-
self.configure_fail_point_sync({}, off=True)
728-
729727
def test_03_drivers_return_the_correct_error_when_receiving_some_errors_with_NoWritesPerformed_and_some_without_NoWritesPerformed(
730728
self
731729
) -> None:
@@ -762,13 +760,15 @@ def failed(event: CommandFailedEvent) -> None:
762760
return
763761
assert event.failure["code"] == 91
764762
self.configure_fail_point_sync(command_args_inner)
763+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
765764
listener.failed_events.append(event)
766765

767766
listener.failed = failed
768767

769768
client = self.rs_client(retryWrites=True, event_listeners=[listener])
770769

771770
self.configure_fail_point_sync(command_args)
771+
self.addCleanup(self.configure_fail_point_sync, {}, off=True)
772772

773773
# Attempt an insertOne operation on any record for any database and collection.
774774
# Expect the insertOne to fail with a server error.
@@ -780,9 +780,6 @@ def failed(event: CommandFailedEvent) -> None:
780780
# Assert that the error does not contain the error label `NoWritesPerformed`.
781781
assert "NoWritesPerformed" not in exc.exception.errors["errorLabels"]
782782

783-
# Disable the fail point.
784-
self.configure_fail_point_sync({}, off=True)
785-
786783

787784
if __name__ == "__main__":
788785
unittest.main()

0 commit comments

Comments
 (0)