Skip to content

Commit c70b66c

Browse files
committed
fix typing
1 parent 73ff3d6 commit c70b66c

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

pymongo/asynchronous/pool.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ def __init__(
793793
self._pending = 0
794794
self._client_id = client_id
795795
self._backoff = 0
796-
self._backoff_connection_time = -1
796+
self._backoff_connection_time = 0.0
797797
if self.enabled_for_cmap:
798798
assert self.opts._event_listeners is not None
799799
self.opts._event_listeners.publish_pool_created(
@@ -1041,11 +1041,11 @@ 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-
error._add_error_label("SystemOverloadedError")
1045-
error._add_error_label("RetryableError")
1044+
error._add_error_label("SystemOverloadedError") # type:ignore[attr-defined]
1045+
error._add_error_label("RetryableError") # type:ignore[attr-defined]
10461046
self.backoff()
10471047

1048-
def backoff(self):
1048+
def backoff(self) -> None:
10491049
"""Set/increase backoff mode."""
10501050
self._backoff += 1
10511051
backoff_duration_sec = _backoff(self._backoff)
@@ -1346,7 +1346,7 @@ async def _get_conn(
13461346
timeout = 0.01
13471347
if not await _async_cond_wait(self._max_connecting_cond, timeout):
13481348
# Check whether we should continue to wait for the backoff condition.
1349-
if self._backoff and deadline is None or deadline < time.monotonic():
1349+
if self._backoff and (deadline is None or deadline < time.monotonic()):
13501350
if self._backoff_connection_time > time.monotonic():
13511351
continue
13521352
break

pymongo/monitoring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ def __init__(self, address: _Address, duration_ms: int) -> None:
943943
self.__duration_ms = duration_ms
944944

945945
@property
946-
def duration_ms(self) -> Optional[ObjectId]:
946+
def duration_ms(self) -> int:
947947
"""The backoff duration in ms."""
948948
return self.__duration_ms
949949

pymongo/synchronous/pool.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ def __init__(
791791
self._pending = 0
792792
self._client_id = client_id
793793
self._backoff = 0
794-
self._backoff_connection_time = -1
794+
self._backoff_connection_time = 0.0
795795
if self.enabled_for_cmap:
796796
assert self.opts._event_listeners is not None
797797
self.opts._event_listeners.publish_pool_created(
@@ -1037,11 +1037,11 @@ 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-
error._add_error_label("SystemOverloadedError")
1041-
error._add_error_label("RetryableError")
1040+
error._add_error_label("SystemOverloadedError") # type:ignore[attr-defined]
1041+
error._add_error_label("RetryableError") # type:ignore[attr-defined]
10421042
self.backoff()
10431043

1044-
def backoff(self):
1044+
def backoff(self) -> None:
10451045
"""Set/increase backoff mode."""
10461046
self._backoff += 1
10471047
backoff_duration_sec = _backoff(self._backoff)
@@ -1342,7 +1342,7 @@ def _get_conn(
13421342
timeout = 0.01
13431343
if not _cond_wait(self._max_connecting_cond, timeout):
13441344
# Check whether we should continue to wait for the backoff condition.
1345-
if self._backoff and deadline is None or deadline < time.monotonic():
1345+
if self._backoff and (deadline is None or deadline < time.monotonic()):
13461346
if self._backoff_connection_time > time.monotonic():
13471347
continue
13481348
break

0 commit comments

Comments
 (0)