diff --git a/gui/app.py b/gui/app.py index 2d0439f..c4891c9 100644 --- a/gui/app.py +++ b/gui/app.py @@ -1645,16 +1645,28 @@ def reports_vendors_update(): "service": service } - thread = threading.Thread( - target=_run_vendor_update, - args=( - job_id, - service - ), - daemon=True - ) + try: - thread.start() + thread = threading.Thread( + target=_run_vendor_update, + args=( + job_id, + service + ), + daemon=True + ) + + thread.start() + + except Exception as error: + + vendor_update_job["status"] = "error" + vendor_update_job["stage"] = "error" + vendor_update_job["source"] = None + vendor_update_job["message"] = None + vendor_update_job["error"] = str( + error + ) job = dict( vendor_update_job @@ -1832,16 +1844,25 @@ def reports_vendors_recalculate(): "result": None } - thread = threading.Thread( - target=_run_vendor_recalculation, - args=( - job_id, - service - ), - daemon=True - ) + try: - thread.start() + thread = threading.Thread( + target=_run_vendor_recalculation, + args=( + job_id, + service + ), + daemon=True + ) + + thread.start() + + except Exception as error: + + vendor_recalc_job["status"] = "error" + vendor_recalc_job["stage"] = "error" + vendor_recalc_job["message"] = None + vendor_recalc_job["error"] = str(error) job = dict( vendor_recalc_job diff --git a/src/vendor_service.py b/src/vendor_service.py index f00d158..9d0d1d2 100644 --- a/src/vendor_service.py +++ b/src/vendor_service.py @@ -1331,13 +1331,47 @@ class VendorService: def iter_rows(): + last_id = None + while True: - batch = rows_cursor.fetchmany(1000) + if last_id is None: + + batch = wifi_conn.execute( + """ + SELECT + id, + bssid, + vendor + FROM access_points + ORDER BY id + LIMIT 1000 + """ + ).fetchall() + + else: + + batch = wifi_conn.execute( + """ + SELECT + id, + bssid, + vendor + FROM access_points + WHERE id > ? + ORDER BY id + LIMIT 1000 + """, + ( + last_id, + ) + ).fetchall() if not batch: break + last_id = batch[-1][0] + yield from batch placeholders = (