diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2019-07-29 10:58:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-29 10:58:22 +0200 |
commit | fa87004bc1ac636d57b8d3b34f5a2414182cb600 (patch) | |
tree | 5a043fc956b6efc8e63d5cf9391bd9e281c0121d /synapse | |
parent | Merge branch 'master' into develop (diff) | |
parent | Changelog (diff) | |
download | synapse-fa87004bc1ac636d57b8d3b34f5a2414182cb600.tar.xz |
Merge pull request #5780 from matrix-org/baboliver/loopingcall-args
Add ability to pass arguments to looping calls
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/util/__init__.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/util/__init__.py b/synapse/util/__init__.py index 841625a991..7856353002 100644 --- a/synapse/util/__init__.py +++ b/synapse/util/__init__.py @@ -59,7 +59,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. @@ -70,8 +70,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(log_failure, "Looping call died", consumeErrors=False) |