diff --git a/tqdm/std.py b/tqdm/std.py index 58e0da1f..8dacf3c1 100644 --- a/tqdm/std.py +++ b/tqdm/std.py @@ -1010,7 +1010,7 @@ class tqdm(Comparable): if not gui: # Initialize the screen printer self.sp = self.status_printer(self.fp) - self.refresh() + self.refresh(lock_args=self.lock_args) # Init the time counter self.last_print_t = self._time() @@ -1292,7 +1292,8 @@ class tqdm(Comparable): if lock_args: if not self._lock.acquire(*lock_args): return False - self._lock.acquire() + else: + self._lock.acquire() self.display() if not nolock: self._lock.release() diff --git a/tqdm/tests/tests_perf.py b/tqdm/tests/tests_perf.py index d19069e3..ffc6d90a 100644 --- a/tqdm/tests/tests_perf.py +++ b/tqdm/tests/tests_perf.py @@ -222,8 +222,9 @@ def test_manual_overhead(): def worker(total, blocking=True): def incr_bar(x): with closing(StringIO()) as our_file: - with tqdm(total=x, lock_args=None if blocking else (False,), - file=our_file, miniters=1, mininterval=0) as t: + with tqdm(total=x, file=our_file, + lock_args=None if blocking else (False,), + miniters=1, mininterval=0, maxinterval=0) as t: for i in range(total): t.update() return x + 1 @@ -242,7 +243,7 @@ def test_lock_args(): import sys total = 8 - subtotal = 10 + subtotal = 100 tqdm.set_lock(RLock()) with ThreadPoolExecutor(total) as pool: @@ -256,9 +257,8 @@ def test_lock_args(): with relative_timer() as time_noblock: res = list(pool.map(worker(subtotal, False), range(total))) assert sum(res) == sum(range(total)) + total - sys.stderr.write('done ... ') - assert_performance(0.99, 'noblock', time_noblock(), 'tqdm', time_tqdm()) + assert_performance(0.2, 'noblock', time_noblock(), 'tqdm', time_tqdm()) @with_setup(pretest, posttest)