fix the WeakSet keyError bug

This commit is contained in:
Guangshuo CHEN 2018-09-10 15:54:02 +08:00 committed by Casper da Costa-Luis
parent 6d33b1178d
commit d19d6476a3
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 3 additions and 1 deletions

View File

@ -478,7 +478,9 @@ class tqdm(Comparable):
"""
with cls._lock:
try:
cls._instances.remove(instance)
if instance in cls._instances:
# in python2 instance maybe magically removed from cls._instances
cls._instances.remove(instance)
except KeyError:
if not instance.gui: # pragma: no cover
raise