mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 03:03:50 +01:00
Add looping_call to Clock
This commit is contained in:
parent
66fde49f07
commit
ef995e6946
1 changed files with 9 additions and 1 deletions
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
from synapse.util.logcontext import LoggingContext
|
from synapse.util.logcontext import LoggingContext
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor, task
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -35,6 +35,14 @@ class Clock(object):
|
||||||
"""Returns the current system time in miliseconds since epoch."""
|
"""Returns the current system time in miliseconds since epoch."""
|
||||||
return self.time() * 1000
|
return self.time() * 1000
|
||||||
|
|
||||||
|
def looping_call(self, f, msec):
|
||||||
|
l = task.LoopingCall(f)
|
||||||
|
l.start(msec/1000.0, now=False)
|
||||||
|
return l
|
||||||
|
|
||||||
|
def stop_looping_call(self, loop):
|
||||||
|
loop.stop()
|
||||||
|
|
||||||
def call_later(self, delay, callback):
|
def call_later(self, delay, callback):
|
||||||
current_context = LoggingContext.current_context()
|
current_context = LoggingContext.current_context()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue