synapse.util package¶
Submodules¶
Module contents¶
-
class
synapse.util.
Clock
(reactor)¶ Bases:
object
A Clock wraps a Twisted reactor and provides utilities on top of it.
- Parameters
reactor – The Twisted reactor to use.
-
call_later
(delay, callback, *args, **kwargs)¶ Call something later
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.
- Parameters
delay (float) – How long to wait in seconds.
callback (function) – Function to call
*args – Postional arguments to pass to function.
**kwargs – Key arguments to pass to function.
-
cancel_call_later
(timer, ignore_errs=False)¶
-
looping_call
(f, msec, *args, **kwargs)¶ Call a function repeatedly.
Waits msec initially before calling f for the first time.
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.
- Parameters
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.
-
sleep
(seconds)¶
-
time
()¶ Returns the current system time in seconds since epoch.
-
time_msec
()¶ Returns the current system time in miliseconds since epoch.
-
synapse.util.
glob_to_regex
(glob)¶ Converts a glob to a compiled regex object.
The regex is anchored at the beginning and end of the string.
- Parameters
glob (str) –
- Returns
re.RegexObject
-
synapse.util.
log_failure
(failure, msg, consumeErrors=True)¶ Creates a function suitable for passing to Deferred.addErrback that logs any failures that occur.
-
synapse.util.
unwrapFirstError
(failure)¶