From 2e829ddeb6b977bb1ea5407a46bde77c26e11f95 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sun, 29 Apr 2018 20:30:22 +0000 Subject: [PATCH] refix #323 --- tqdm/_monitor.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tqdm/_monitor.py b/tqdm/_monitor.py index 534acd74..f6bca825 100644 --- a/tqdm/_monitor.py +++ b/tqdm/_monitor.py @@ -66,14 +66,13 @@ class TMonitor(Thread): with self.tqdm_cls.get_lock(): cur_t = self._time() # Check tqdm instances are waiting too long to print - instances = self.tqdm_cls._instances.copy() + instances = [i for i in self.tqdm_cls._instances.copy() + # Avoid race by checking that the instance started + if hasattr(i, 'start_t')] for instance in instances: # Check event in loop to reduce blocking time on exit if self.was_killed.is_set(): return - # Avoid race by checking that the instance started - if not hasattr(instance, 'start_t'): # pragma: nocover - continue # Only if mininterval > 1 (else iterations are just slow) # and last refresh exceeded maxinterval if instance.miniters > 1 and \