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

Commit 8ddb2de

Browse files
Document looping_call() functionality that will wait for the given function to finish before scheduling another (#15772)
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 553f2f5 commit 8ddb2de

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

changelog.d/15772.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Document `looping_call()` functionality that will wait for the given function to finish before scheduling another.

synapse/util/__init__.py

Lines changed: 5 additions & 0 deletions
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)