From e0937a4e82b60d0e9244c95102494b7da299822d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Thu, 17 Aug 2023 14:11:10 +0200 Subject: [PATCH] Cleanup loop --- pynitrokey/cli/nk3/test.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pynitrokey/cli/nk3/test.py b/pynitrokey/cli/nk3/test.py index f9388732..d78001e7 100644 --- a/pynitrokey/cli/nk3/test.py +++ b/pynitrokey/cli/nk3/test.py @@ -374,21 +374,22 @@ def internal_se050_run(q: Queue[Optional[bytes]]) -> None: t = Thread(target=internal_se050_run, args=[que]) t.start() + total = 900 bar = tqdm( - desc="Running SE050 test", unit="%", bar_format="{l_bar}{bar}", total=900 + desc="Running SE050 test", unit="%", bar_format="{l_bar}{bar}", total=total ) # 1m30 in increments of 0.1 second - for i in range(900): + for i in range(total): t.join(0.1) bar.update(1) if not t.is_alive(): break - if i == 900 - 1: - bar.close() - return TestResult( - TestStatus.FAILURE, - "Test timed out after 1m30", - ) + else: + bar.close() + return TestResult( + TestStatus.FAILURE, + "Test timed out after 1m30", + ) bar.close() result = que.get()