diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 06705b71ad..4f9b6f9aa6 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -168,7 +168,6 @@ class Plugins(collections.Mapping): 'chm_extra', 'icu', 'speedup', - 'monotonic', 'unicode_names', 'zlib2', 'html', @@ -183,6 +182,10 @@ class Plugins(collections.Mapping): 'certgen', 'lzma_binding', ] + if not ispy3: + plugins.extend([ + 'monotonic', + ]) if iswindows: plugins.extend(['winutil', 'wpd', 'winfonts']) if isosx: diff --git a/src/calibre/utils/monotonic.py b/src/calibre/utils/monotonic.py index da6c88249e..6bf33e46d8 100644 --- a/src/calibre/utils/monotonic.py +++ b/src/calibre/utils/monotonic.py @@ -1,9 +1,12 @@ # vim:fileencoding=utf-8 -from calibre.constants import plugins +try: + from time import monotonic +except ImportError: + from calibre.constants import plugins -monotonicp, err = plugins['monotonic'] -if err: - raise RuntimeError('Failed to load the monotonic module with error: ' + err) -monotonic = monotonicp.monotonic -del monotonicp, err + monotonicp, err = plugins['monotonic'] + if err: + raise RuntimeError('Failed to load the monotonic module with error: ' + err) + monotonic = monotonicp.monotonic + del monotonicp, err