This commit is contained in:
Casper da Costa-Luis 2020-10-06 18:46:10 +01:00
parent bdad681aa3
commit a8317c9268
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
3 changed files with 7 additions and 1 deletions

View File

@ -546,7 +546,7 @@ class tqdm(Comparable):
'{0}{1} [{2}, {3}{4}]'.format(
n_fmt, unit, elapsed_str, rate_fmt, postfix)
def __new__(cls, *args, **_):
def __new__(cls, *_, **__):
# Create a new instance
instance = object.__new__(cls)
# Construct the lock if it does not exist

View File

@ -15,18 +15,22 @@ class Time(object):
@classmethod
def reset(cls):
"""zeroes internal offset"""
cls.offset = 0
@classmethod
def time(cls):
"""time.time() + offset"""
return time() + cls.offset
@staticmethod
def sleep(dur):
"""identical to time.sleep()"""
return sleep(dur)
@classmethod
def fake_sleep(cls, dur):
"""adds `dur` to internal offset"""
cls.offset += dur
sleep(0.000001) # sleep to allow interrupt (instead of pass)

View File

@ -1811,8 +1811,10 @@ def patch_lock(thread=True):
raise SkipTest
def outer(func):
"""actual decorator"""
@wraps(func)
def inner(*args, **kwargs):
"""set & reset lock even if exceptions occur"""
default_lock = tqdm.get_lock()
try:
tqdm.set_lock(lock)