Skip to content

Commit e3f2f26

Browse files
committed
Consolidate condition waits
1 parent abb3880 commit e3f2f26

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

test/asynchronous/utils_spec_runner.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
from pymongo.asynchronous.command_cursor import AsyncCommandCursor
4848
from pymongo.asynchronous.cursor import AsyncCursor
4949
from pymongo.errors import AutoReconnect, BulkWriteError, OperationFailure, PyMongoError
50-
from pymongo.lock import _async_create_condition, _async_create_lock
50+
from pymongo.lock import _async_cond_wait, _async_create_condition, _async_create_lock
5151
from pymongo.read_concern import ReadConcern
5252
from pymongo.read_preferences import ReadPreference
5353
from pymongo.results import BulkWriteResult, _WriteResult
@@ -98,10 +98,7 @@ async def run(self):
9898
while not self.stopped or self.ops:
9999
if not self.ops:
100100
async with self.cond:
101-
if _IS_SYNC:
102-
await self.cond.wait(10) # type: ignore[call-arg]
103-
else:
104-
await asyncio.wait_for(self.cond.wait(), timeout=10) # type: ignore[arg-type]
101+
await _async_cond_wait(self.cond, 10)
105102
if self.ops:
106103
try:
107104
work = self.ops.pop(0)

test/utils_spec_runner.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from gridfs import GridFSBucket
4545
from gridfs.synchronous.grid_file import GridFSBucket
4646
from pymongo.errors import AutoReconnect, BulkWriteError, OperationFailure, PyMongoError
47-
from pymongo.lock import _create_condition, _create_lock
47+
from pymongo.lock import _cond_wait, _create_condition, _create_lock
4848
from pymongo.read_concern import ReadConcern
4949
from pymongo.read_preferences import ReadPreference
5050
from pymongo.results import BulkWriteResult, _WriteResult
@@ -98,10 +98,7 @@ def run(self):
9898
while not self.stopped or self.ops:
9999
if not self.ops:
100100
with self.cond:
101-
if _IS_SYNC:
102-
self.cond.wait(10) # type: ignore[call-arg]
103-
else:
104-
asyncio.wait_for(self.cond.wait(), timeout=10) # type: ignore[arg-type]
101+
_cond_wait(self.cond, 10)
105102
if self.ops:
106103
try:
107104
work = self.ops.pop(0)

0 commit comments

Comments
 (0)