From fb8d042f48f16c8a83b6a56d8a3ebf2ad753138b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 13 Sep 2013 14:31:25 -0400 Subject: [PATCH] Add monotic time util function --- confluent/util.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/confluent/util.py b/confluent/util.py index 677d9def..9bb2e1c4 100644 --- a/confluent/util.py +++ b/confluent/util.py @@ -34,3 +34,13 @@ def securerandomnumber(min=0, max=4294967295): number = struct.unpack("I",os.urandom(4))[0] return number +def monotonic_time(): + """Return a monotoc time value + + In scenarios like timeouts and such, monotonic timing is preferred. + """ + if (os.name == "posix"): + return os.times()[4] + else: + return time.time() + #TODO: windows?