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
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)¶ Call a function repeatedly.
Waits msec initially before calling f for the first time.Parameters: - f (function) – The function to call repeatedly.
- msec (float) – How long to wait between calls in milliseconds.
-
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.
batch_iter
(iterable, size)¶ batch an iterable up into tuples with a maximum size
Parameters: - iterable (iterable) – the iterable to slice
- size (int) – the maximum batch size
Returns: an iterator over the chunks
-
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.
Parameters: Returns: func(Failure)
-
synapse.util.
unwrapFirstError
(failure)¶