You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: RELEASE_NOTES.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ This release adds support to pass `None` values via channels and revamps the `Ti
8
8
9
9
*`util.Timer` was replaced by a more generic implementation that allows for customizable policies to handle missed ticks.
10
10
11
-
If you were using `Timer` to implement timeouts, these two pices of code should be almost equivalent:
11
+
If you were using `Timer` to implement timeouts, these two pieces of code should be almost equivalent:
12
12
13
13
- Old:
14
14
@@ -27,7 +27,7 @@ This release adds support to pass `None` values via channels and revamps the `Ti
27
27
28
28
They are not**exactly** the same because the `triggered_datetime`in the second case will not be exactly when the timer had triggered, but that shouldn't be relevant, the important part is when your code can actually react to the timer trigger and to know how much drift there was to be able to take corrective actions.
29
29
30
-
Also the new `Timer` uses the `asyncio` loop monotonic clock and the old one used the wall clock (`datetime.now()`) to track time. This means that when using `async-solipsism` to test, the new `Timer` will always trigger immediately regarless of the state of the wall clock. This also means that we don't need to mock the wall clock with `time-machine` either now.
30
+
Also the new `Timer` uses the `asyncio` loop monotonic clock and the old one used the wall clock (`datetime.now()`) to track time. This means that when using `async-solipsism` to test, the new `Timer` will always trigger immediately regardless of the state of the wall clock. This also means that we don't need to mock the wall clock with `time-machine` either now.
31
31
32
32
With the previous timer one needed to create a separate task to run the timer, because otherwise it would block as it loops until the wall clock was at a specific time. Now the code will run like this:
33
33
@@ -39,7 +39,7 @@ This release adds support to pass `None` values via channels and revamps the `Ti
39
39
40
40
# Simulates a delay in the timer trigger time
41
41
asyncio.sleep(1.5) # Advances the loop monotonic clock by 1.5 seconds immediately
42
-
await drift = timer.receive() # The timer should have triggerd 0.5 seconds ago, so it doesn't even sleep
42
+
await drift = timer.receive() # The timer should have triggered 0.5 seconds ago, so it doesn't even sleep
43
43
assert drift == approx(timedelta(seconds=0.5)) # Now we should observe a drift of 0.5 seconds
0 commit comments