summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2023-06-13 16:34:54 -0500
committerGitHub <noreply@github.com>2023-06-13 16:34:54 -0500
commit8ddb2de55387d54bac53138f374f55c7608991ce (patch)
treede00021624bb076021113dbdbcd25d2a5eb76199
parentReplace `EventContext` fields `prev_group` and `delta_ids` with field `state_... (diff)
downloadsynapse-8ddb2de55387d54bac53138f374f55c7608991ce.tar.xz
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.
-rw-r--r--changelog.d/15772.doc1
-rw-r--r--synapse/util/__init__.py5
2 files changed, 6 insertions, 0 deletions
diff --git a/changelog.d/15772.doc b/changelog.d/15772.doc
new file mode 100644
index 0000000000..4d6c933c71
--- /dev/null
+++ b/changelog.d/15772.doc
@@ -0,0 +1 @@
+Document `looping_call()` functionality that will wait for the given function to finish before scheduling another.
diff --git a/synapse/util/__init__.py b/synapse/util/__init__.py
index 7ea0c4c36b..9f3b8741c1 100644
--- a/synapse/util/__init__.py
+++ b/synapse/util/__init__.py
@@ -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.