mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-26 12:16:12 +00:00
Add ability to pass arguments to looping calls
This commit is contained in:
parent
d74595e2ca
commit
08352d44f8
@ -59,7 +59,7 @@ class Clock(object):
|
|||||||
"""Returns the current system time in miliseconds since epoch."""
|
"""Returns the current system time in miliseconds since epoch."""
|
||||||
return int(self.time() * 1000)
|
return int(self.time() * 1000)
|
||||||
|
|
||||||
def looping_call(self, f, msec):
|
def looping_call(self, f, msec, *args):
|
||||||
"""Call a function repeatedly.
|
"""Call a function repeatedly.
|
||||||
|
|
||||||
Waits `msec` initially before calling `f` for the first time.
|
Waits `msec` initially before calling `f` for the first time.
|
||||||
@ -71,7 +71,7 @@ class Clock(object):
|
|||||||
f(function): The function to call repeatedly.
|
f(function): The function to call repeatedly.
|
||||||
msec(float): How long to wait between calls in milliseconds.
|
msec(float): How long to wait between calls in milliseconds.
|
||||||
"""
|
"""
|
||||||
call = task.LoopingCall(f)
|
call = task.LoopingCall(f, *args)
|
||||||
call.clock = self._reactor
|
call.clock = self._reactor
|
||||||
d = call.start(msec / 1000.0, now=False)
|
d = call.start(msec / 1000.0, now=False)
|
||||||
d.addErrback(log_failure, "Looping call died", consumeErrors=False)
|
d.addErrback(log_failure, "Looping call died", consumeErrors=False)
|
||||||
|
Loading…
Reference in New Issue
Block a user