File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change 1313 ```
1414
1515* ` Receiver.filter() ` can now properly handle ` TypeGuard ` s. The resulting receiver will now have the narrowed type when a ` TypeGuard ` is used.
16+
17+ ## Bug Fixes
18+
19+ - Fixed a memory leak in the timer.
Original file line number Diff line number Diff line change @@ -684,14 +684,20 @@ async def ready(self) -> bool: # noqa: DOC502
684684 # could be reset while we are sleeping, in which case we need to recalculate
685685 # the time to the next tick and try again.
686686 while time_to_next_tick > 0 :
687- await next (
688- asyncio .as_completed (
689- [
690- asyncio .sleep (time_to_next_tick / 1_000_000 ),
691- self ._reset_event .wait (),
692- ]
693- )
687+ _ , pending = await asyncio .wait (
688+ [
689+ asyncio .create_task (asyncio .sleep (time_to_next_tick / 1_000_000 )),
690+ asyncio .create_task (self ._reset_event .wait ()),
691+ ],
692+ return_when = asyncio .FIRST_COMPLETED ,
694693 )
694+ for task in pending :
695+ task .cancel ()
696+ try :
697+ await task
698+ except asyncio .CancelledError :
699+ pass
700+
695701 self ._reset_event .clear ()
696702 now = self ._now ()
697703 time_to_next_tick = self ._next_tick_time - now
You can’t perform that action at this time.
0 commit comments