Skip to content

Commit c92f6af

Browse files
committed
add missing await and fix typing errors
1 parent 549645b commit c92f6af

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

pymongo/asynchronous/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ async def _check_server(self) -> ServerDescription:
250250
except (OperationFailure, NotPrimaryError) as exc:
251251
# Update max cluster time even when hello fails.
252252
details = cast(Mapping[str, Any], exc.details)
253-
self._topology.receive_cluster_time(details.get("$clusterTime"))
253+
await self._topology.receive_cluster_time(details.get("$clusterTime"))
254254
raise
255255
except ReferenceError:
256256
raise

pymongo/asynchronous/periodic_executor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def close(self, dummy: Any = None) -> None:
8181
async def join(self, timeout: Optional[int] = None) -> None:
8282
if self._task is not None:
8383
try:
84-
await asyncio.wait_for(self._task, timeout=timeout)
84+
await asyncio.wait_for(self._task, timeout=timeout) # type-ignore: [arg-type]
8585
except asyncio.TimeoutError:
8686
# Task timed out
8787
pass
@@ -274,7 +274,7 @@ def _on_executor_deleted(ref: weakref.ReferenceType[PeriodicExecutor]) -> None:
274274
_EXECUTORS.remove(ref)
275275

276276

277-
async def _shutdown_executors() -> None:
277+
def _shutdown_executors() -> None:
278278
if _EXECUTORS is None:
279279
return
280280

@@ -291,6 +291,6 @@ async def _shutdown_executors() -> None:
291291
for ref in executors:
292292
executor = ref()
293293
if executor:
294-
await executor.join(1)
294+
executor.join(1)
295295

296296
executor = None

pymongo/asynchronous/topology.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ async def _select_servers_loop(
359359
await self._condition.wait(common.MIN_HEARTBEAT_INTERVAL)
360360
else:
361361
try:
362-
await asyncio.wait_for(self._condition.wait(), common.MIN_HEARTBEAT_INTERVAL)
362+
await asyncio.wait_for(
363+
self._condition.wait(), common.MIN_HEARTBEAT_INTERVAL
364+
) # type-ignore: [arg-type]
363365
except asyncio.TimeoutError:
364366
pass
365367
self._description.check_compatible()
@@ -665,8 +667,10 @@ async def request_check_all(self, wait_time: int = 5) -> None:
665667
await self._condition.wait(wait_time)
666668
else:
667669
try:
668-
await asyncio.wait_for(self._condition.wait(), wait_time)
669-
except TimeoutError:
670+
await asyncio.wait_for(
671+
self._condition.wait(), wait_time
672+
) # type-ignore: [arg-type]
673+
except asyncio.TimeoutError:
670674
pass
671675

672676
def data_bearing_servers(self) -> list[ServerDescription]:

pymongo/synchronous/periodic_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def close(self, dummy: Any = None) -> None:
8181
def join(self, timeout: Optional[int] = None) -> None:
8282
if self._task is not None:
8383
try:
84-
asyncio.wait_for(self._task, timeout=timeout)
84+
asyncio.wait_for(self._task, timeout=timeout) # type-ignore: [arg-type]
8585
except asyncio.TimeoutError:
8686
# Task timed out
8787
pass

pymongo/synchronous/topology.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ def _select_servers_loop(
359359
self._condition.wait(common.MIN_HEARTBEAT_INTERVAL)
360360
else:
361361
try:
362-
asyncio.wait_for(self._condition.wait(), common.MIN_HEARTBEAT_INTERVAL)
362+
asyncio.wait_for(
363+
self._condition.wait(), common.MIN_HEARTBEAT_INTERVAL
364+
) # type-ignore: [arg-type]
363365
except asyncio.TimeoutError:
364366
pass
365367
self._description.check_compatible()
@@ -663,8 +665,8 @@ def request_check_all(self, wait_time: int = 5) -> None:
663665
self._condition.wait(wait_time)
664666
else:
665667
try:
666-
asyncio.wait_for(self._condition.wait(), wait_time)
667-
except TimeoutError:
668+
asyncio.wait_for(self._condition.wait(), wait_time) # type-ignore: [arg-type]
669+
except asyncio.TimeoutError:
668670
pass
669671

670672
def data_bearing_servers(self) -> list[ServerDescription]:

0 commit comments

Comments
 (0)