From 19a0aa139dec64032544ed90da1281b0a23faf43 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 9 Nov 2020 19:47:41 +0530 Subject: [PATCH] Fix #1903535 [[PATCH] Allow keyword arguments in debug_print](https://bugs.launchpad.net/calibre/+bug/1903535) --- src/calibre/devices/usbms/driver.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/calibre/devices/usbms/driver.py b/src/calibre/devices/usbms/driver.py index d8c8ada680..e56cdb3381 100644 --- a/src/calibre/devices/usbms/driver.py +++ b/src/calibre/devices/usbms/driver.py @@ -23,15 +23,13 @@ from calibre.devices.usbms.books import BookList, Book from calibre.ebooks.metadata.book.json_codec import JsonCodec from polyglot.builtins import itervalues, unicode_type, string_or_bytes, zip -BASE_TIME = None - -def debug_print(*args): - global BASE_TIME - if BASE_TIME is None: - BASE_TIME = time.time() +def debug_print(*args, **kw): + base_time = getattr(debug_print, 'base_time', None) + if base_time is None: + debug_print.base_time = base_time = time.monotonic() if DEBUG: - prints('DEBUG: %6.1f'%(time.time()-BASE_TIME), *args) + prints('DEBUG: %6.1f'%(time.monotonic()-base_time), *args, **kw) def safe_walk(top, topdown=True, onerror=None, followlinks=False, maxdepth=128):