diff options
author | Michael Kaye <1917473+michaelkaye@users.noreply.github.com> | 2019-08-08 12:10:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-08 12:10:36 +0100 |
commit | 63d0d21a28cc8282778e3b5f02a2acfd66d97ad5 (patch) | |
tree | a6ccc79dc0c1bfd63d1f49391a1b15ca87dda48f | |
parent | Merge pull request #5760 from matrix-org/babolivier/access-rules-public-restr... (diff) | |
parent | Changelog (diff) | |
download | synapse-63d0d21a28cc8282778e3b5f02a2acfd66d97ad5.tar.xz |
Merge pull request #5781 from matrix-org/baboliver/loopingcall-args dinsic_2019-08-08
Add ability to pass arguments to looping calls
-rw-r--r-- | changelog.d/5780.misc | 1 | ||||
-rw-r--r-- | synapse/util/__init__.py | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/changelog.d/5780.misc b/changelog.d/5780.misc new file mode 100644 index 0000000000..b7eb56e625 --- /dev/null +++ b/changelog.d/5780.misc @@ -0,0 +1 @@ +Allow looping calls to be given arguments. diff --git a/synapse/util/__init__.py b/synapse/util/__init__.py index 0ae7e2ef3b..8f5a526800 100644 --- a/synapse/util/__init__.py +++ b/synapse/util/__init__.py @@ -58,7 +58,7 @@ class Clock(object): """Returns the current system time in miliseconds since epoch.""" return int(self.time() * 1000) - def looping_call(self, f, msec): + def looping_call(self, f, msec, *args, **kwargs): """Call a function repeatedly. Waits `msec` initially before calling `f` for the first time. @@ -66,8 +66,10 @@ class Clock(object): Args: f(function): The function to call repeatedly. msec(float): How long to wait between calls in milliseconds. + *args: Postional arguments to pass to function. + **kwargs: Key arguments to pass to function. """ - call = task.LoopingCall(f) + call = task.LoopingCall(f, *args, **kwargs) call.clock = self._reactor d = call.start(msec / 1000.0, now=False) d.addErrback( |