diff options
author | Ask Solem <ask@celeryproject.org> | 2013-11-03 15:24:02 +0000 |
---|---|---|
committer | Ask Solem <ask@celeryproject.org> | 2013-11-03 15:24:02 +0000 |
commit | 4ad0073efbb0f54a5141fb4f10c4eb6d7d5d5eb6 (patch) | |
tree | ed54da95a4639f81f9ffb0981383e8f932b5773f | |
parent | c5a899d376cbb4be5ef55168cfe32e232b66cd42 (diff) | |
download | kombu-4ad0073efbb0f54a5141fb4f10c4eb6d7d5d5eb6.tar.gz |
Removes duplicate monotonic
-rw-r--r-- | kombu/utils/compat.py | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/kombu/utils/compat.py b/kombu/utils/compat.py index 181cc40c..16028997 100644 --- a/kombu/utils/compat.py +++ b/kombu/utils/compat.py @@ -58,52 +58,3 @@ try: from collections import OrderedDict except ImportError: from ordereddict import OrderedDict # noqa - -############## time.monotonic ################################################ - -import platform -SYSTEM = platform.system() - -if SYSTEM == 'Darwin': - import ctypes - libSystem = ctypes.CDLL('libSystem.dylib') - CoreServices = ctypes.CDLL( - '/System/Library/Frameworks/CoreServices.framework/CoreServices', - use_errno=True, - ) - mach_absolute_time = libSystem.mach_absolute_time - mach_absolute_time.restype = ctypes.c_uint64 - absolute_to_nanoseconds = CoreServices.AbsoluteToNanoseconds - absolute_to_nanoseconds.restype = ctypes.c_uint64 - absolute_to_nanoseconds.argtypes = [ctypes.c_uint64] - - def monotonic(): - return absolute_to_nanoseconds(mach_absolute_time()) * 1e-9 -elif SYSTEM == 'Linux': - # from stackoverflow: - # questions/1205722/how-do-i-get-monotonic-time-durations-in-python - import ctypes - import os - - CLOCK_MONOTONIC = 1 # see <linux/time.h> - - class timespec(ctypes.Structure): - _fields_ = [ - ('tv_sec', ctypes.c_long), - ('tv_nsec', ctypes.c_long), - ] - - librt = ctypes.CDLL('librt.so.1', use_errno=True) - clock_gettime = librt.clock_gettime - clock_gettime.argtypes = [ - ctypes.c_int, ctypes.POINTER(timespec), - ] - - def monotonic(): # noqa - t = timespec() - if clock_gettime(CLOCK_MONOTONIC, ctypes.pointer(t)) != 0: - errno_ = ctypes.get_errno() - raise OSError(errno_, os.strerror(errno_)) - return t.tv_sec + t.tv_nsec * 1e-9 -else: - from time import time as monotonic # noqa |