The following is a API reference of Autobahn generated from Python source code and docstrings.
Warning
This is a complete reference of both the public API and the internal API of Autobahn. Applications should only rely on the public API, since internal APIs can (and often do) change without any guarantees.
autobahn.util.
utcnow
()[source]¶Get current time in UTC as ISO 8601 string.
Returns: | Current time as string in ISO 8601 format. |
---|---|
Return type: | unicode |
autobahn.util.
utcstr
(ts)[source]¶Format UTC timestamp in ISO 8601 format.
Parameters: | ts (instance of datetime.datetime ) – The timestamp to format. |
---|---|
Returns: | Timestamp formatted in ISO 8601 format. |
Return type: | unicode |
autobahn.util.
parseutc
(datestr)[source]¶Parse an ISO 8601 combined date and time string, like i.e. "2011-11-23T12:23:00Z"
into a UTC datetime instance.
Deprecated since version 0.8.12: Use the iso8601 module instead (e.g. iso8601.parse_date("2014-05-23T13:03:44.123Z")
)
Parameters: | datestr (unicode) – The datetime string to parse. |
---|---|
Returns: | The converted datetime object. |
Return type: | instance of datetime.datetime |
autobahn.util.
id
()[source]¶Generate a new random object ID from range [0, 2**53].
The upper bound 2**53 is chosen since it is the maximum integer that can be represented as a IEEE double such that all smaller integers are representable as well.
Hence, IDs can be safely used with languages that use IEEE double as their main (or only) number type (JavaScript, Lua, etc).
Returns: | A random object ID. |
---|---|
Return type: | int |
autobahn.util.
newid
(length=16)[source]¶Generate a new random object ID.
Parameters: | length (int) – The length (in chars) of the ID to generate. |
---|---|
Returns: | A random object ID. |
Return type: | str |
autobahn.util.
rtime
()¶Precise wallclock time.
Returns: | The current wallclock in seconds. Returned values are only guaranteed to be meaningful relative to each other. |
---|---|
Return type: | float |
autobahn.util.
Stopwatch
(start=True)[source]¶Stopwatch based on walltime.
This can be used to do code timing and uses the most precise walltime measurement available on the platform. This is a very light-weight object, so create/dispose is very cheap.
Parameters: | start (bool) – If True , immediately start the stopwatch. |
---|
elapsed
()[source]¶Return total time elapsed in seconds during which the stopwatch was running.
Returns: | The elapsed time in seconds. |
---|---|
Return type: | float |
pause
()[source]¶Pauses the stopwatch and returns total time elapsed in seconds during which the stopwatch was running.
Returns: | The elapsed time in seconds. |
---|---|
Return type: | float |
autobahn.util.
Tracker
(tracker, tracked)[source]¶A key-based statistics tracker.
track
(key)[source]¶Track elapsed for key.
Parameters: | key (str) – Key under which to track the timing. |
---|
diff
(startKey, endKey, formatted=True)[source]¶Get elapsed difference between two previously tracked keys.
Parameters: | |
---|---|
Returns: | Computed time period in seconds (or formatted string). |
Return type: | float or str |
absolute
(key)[source]¶Return the UTC wall-clock time at which a tracked event occurred.
Parameters: | key (str) – The key |
---|---|
Returns: | Timezone-naive datetime. |
Return type: | instance of datetime.datetime |