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

Commit

Permalink
Document looping_call() functionality that will wait for the given …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
MadLittleMods authored Jun 13, 2023
1 parent 553f2f5 commit 8ddb2de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/15772.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document `looping_call()` functionality that will wait for the given function to finish before scheduling another.
5 changes: 5 additions & 0 deletions synapse/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def looping_call(
Waits `msec` initially before calling `f` for the first time.
If the function given to `looping_call` returns an awaitable/deferred, the next
call isn't scheduled until after the returned awaitable has finished. We get
this functionality thanks to this function being a thin wrapper around
`twisted.internet.task.LoopingCall`.
Note that the function will be called with no logcontext, so if it is anything
other than trivial, you probably want to wrap it in run_as_background_process.
Expand Down

0 comments on commit 8ddb2de

Please sign in to comment.