async-timer 1.1.4__tar.gz → 1.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {async_timer-1.1.4 → async_timer-1.1.6}/PKG-INFO +1 -1
- {async_timer-1.1.4 → async_timer-1.1.6}/pyproject.toml +1 -1
- {async_timer-1.1.4 → async_timer-1.1.6}/src/async_timer/timer.py +4 -0
- {async_timer-1.1.4 → async_timer-1.1.6}/src/mock_async_timer/timer.py +8 -1
- {async_timer-1.1.4 → async_timer-1.1.6}/README.md +0 -0
- {async_timer-1.1.4 → async_timer-1.1.6}/src/async_timer/__init__.py +0 -0
- {async_timer-1.1.4 → async_timer-1.1.6}/src/async_timer/pacemaker.py +0 -0
- {async_timer-1.1.4 → async_timer-1.1.6}/src/async_timer/traget_caller.py +0 -0
- {async_timer-1.1.4 → async_timer-1.1.6}/src/mock_async_timer/__init__.py +0 -0
|
@@ -110,6 +110,10 @@ class Timer(typing.Generic[T]):
|
|
|
110
110
|
"""A shorthand to access timer firing delay"""
|
|
111
111
|
return self.pacemaker.delay
|
|
112
112
|
|
|
113
|
+
def set_delay(self, new_delay: float):
|
|
114
|
+
"""Change the delay."""
|
|
115
|
+
self.pacemaker.delay = new_delay
|
|
116
|
+
|
|
113
117
|
def start(self):
|
|
114
118
|
"""Schedule the timer to run."""
|
|
115
119
|
if self.main_task:
|
|
@@ -24,6 +24,13 @@ class MockPacemaker(async_timer.pacemaker.TimerPacemaker):
|
|
|
24
24
|
asyncio.get_event_loop().call_soon(lambda: fut.set_result(42))
|
|
25
25
|
await fut
|
|
26
26
|
|
|
27
|
+
@classmethod
|
|
28
|
+
def fromPacemaker(cls, original: async_timer.pacemaker.TimerPacemaker):
|
|
29
|
+
"""Create MockPacemaker from the non-mock original."""
|
|
30
|
+
out = cls(delay=original.delay)
|
|
31
|
+
out.stop_on(original._cancel_futs)
|
|
32
|
+
return out
|
|
33
|
+
|
|
27
34
|
|
|
28
35
|
class MockTimer(async_timer.Timer):
|
|
29
36
|
"""Test-friendly mock timer class.
|
|
@@ -36,4 +43,4 @@ class MockTimer(async_timer.Timer):
|
|
|
36
43
|
|
|
37
44
|
def __init__(self, *args, **kwargs):
|
|
38
45
|
super().__init__(*args, **kwargs)
|
|
39
|
-
self.pacemaker = MockPacemaker(self.pacemaker
|
|
46
|
+
self.pacemaker = MockPacemaker.fromPacemaker(self.pacemaker)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|