From 52963e2fe6c57bd90c1d45e21cc2db3b1b5e393b Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 13 Feb 2020 20:18:20 -0800 Subject: [PATCH] Catch ctrl+c to commit before quitting. --- droidz.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/droidz.py b/droidz.py index 0c64340..508d852 100644 --- a/droidz.py +++ b/droidz.py @@ -261,7 +261,10 @@ def incremental_update(threads=1): ids = [row[0] for row in cur.fetchall()] sticks = scrape_directs(ids, threads=threads) - insert_sticks(sticks) + try: + insert_sticks(sticks) + except KeyboardInterrupt: + sql.commit() def full_update(threads=1): for category in CATEGORIES: @@ -273,7 +276,10 @@ def full_update(threads=1): ids = [row[0] for row in cur.fetchall()] sticks = scrape_directs(ids, threads=threads) - insert_sticks(sticks) + try: + insert_sticks(sticks) + except KeyboardInterrupt: + sql.commit() # DOWNLOAD ################################################################################