potential thread safety fix

- related: #548
This commit is contained in:
Casper da Costa-Luis 2019-08-27 14:49:53 +01:00
parent 96cd73ec03
commit a3477060f1
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 7 additions and 3 deletions

View File

@ -1022,9 +1022,13 @@ class tqdm(Comparable):
def __enter__(self):
return self
def __exit__(self, *exc):
self.close()
return False
def __exit__(self, exc_type, exc_value, traceback):
try:
self.close()
except AttributeError:
# maybe eager thread cleanup upon external error
if exc_type is None:
raise
def __del__(self):
self.close()