Skip to content

Commit 02b4458

Browse files
committed
init_db scrip now display a nice message on KeyboardInterrupt
1 parent 6e21ca4 commit 02b4458

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/init_scripts/init_db_with_password_file.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ def download_rockyou(download_file):
8989
password_count += 1
9090

9191
redis_client = Redis.from_url(str(settings.kvrocks_url))
92-
init_db(password_path, db_client=redis_client, password_count=password_count)
93-
duration = time.time() - start
94-
print(f"Took {duration:.2f}s")
92+
try:
93+
init_db(password_path, db_client=redis_client, password_count=password_count)
94+
except KeyboardInterrupt:
95+
print("[red]Cancelled by user")
96+
finally:
97+
duration = time.time() - start
98+
print(f"Took {duration:.2f}s")

0 commit comments

Comments
 (0)