Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit ec2c17d

Browse files
committed
looping_call() will wait for the given function to finish before scheduling another
Thanks to @erikjohnston for clarifying, #15743 (comment) We don't have to worry about calls stacking up if the given function takes longer than the scheduled time.
1 parent ba97b39 commit ec2c17d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

synapse/util/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ def looping_call(
116116
117117
Waits `msec` initially before calling `f` for the first time.
118118
119+
If the function given to `looping_call` returns an awaitable/deferred, the next
120+
call isn't scheduled until after the returned awaitable has finished. We get
121+
this functionality thanks to this function being a thin wrapper around
122+
`twisted.internet.task.LoopingCall`.
123+
119124
Note that the function will be called with no logcontext, so if it is anything
120125
other than trivial, you probably want to wrap it in run_as_background_process.
121126

0 commit comments

Comments
 (0)