Document looping_call() functionality that will wait for the given function to finish before scheduling another (#15772)

Thanks to @erikjohnston for clarifying, https://github.com/matrix-org/synapse/pull/15743#discussion_r1226544457

We don't have to worry about calls stacking up if the given function takes longer than the scheduled time.
This commit is contained in:
Eric Eastwood 2023-06-13 16:34:54 -05:00 committed by GitHub
parent 553f2f53e7
commit 8ddb2de553
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

1
changelog.d/15772.doc Normal file
View File

@ -0,0 +1 @@
Document `looping_call()` functionality that will wait for the given function to finish before scheduling another.

View File

@ -116,6 +116,11 @@ class Clock:
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.