Skip to content

Commit 4160761

Browse files
committed
PYTHON-5784 Fix update_interval type annotation to float
update_interval() stores into _interval (float) and is called with float values, but was annotated new_interval: int. Correct the annotation on both executors and use a small positive interval in the coverage test.
1 parent 1b86197 commit 4160761

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

pymongo/periodic_executor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def wake(self) -> None:
8787
"""Execute the target function soon."""
8888
self._event = True
8989

90-
def update_interval(self, new_interval: int) -> None:
90+
def update_interval(self, new_interval: float) -> None:
9191
self._interval = new_interval
9292

9393
def skip_sleep(self) -> None:
@@ -217,7 +217,7 @@ def wake(self) -> None:
217217
"""Execute the target function soon."""
218218
self._event = True
219219

220-
def update_interval(self, new_interval: int) -> None:
220+
def update_interval(self, new_interval: float) -> None:
221221
self._interval = new_interval
222222

223223
def skip_sleep(self) -> None:

test/asynchronous/test_periodic_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ async def target():
117117
call_times.append(time.monotonic())
118118
if len(call_times) == 1:
119119
# Shorten the interval from 30s so the next run happens promptly.
120-
executor.update_interval(0)
120+
executor.update_interval(0.05)
121121
return True
122122
return False
123123

test/test_periodic_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def target():
117117
call_times.append(time.monotonic())
118118
if len(call_times) == 1:
119119
# Shorten the interval from 30s so the next run happens promptly.
120-
executor.update_interval(0)
120+
executor.update_interval(0.05)
121121
return True
122122
return False
123123

0 commit comments

Comments
 (0)