Skia has proposed merging ~hyask/autopkgtest-cloud:skia/d-r_fix_locking into autopkgtest-cloud:master.
Requested reviews: Canonical's Ubuntu QA (canonical-ubuntu-qa) For more details, see: https://code.launchpad.net/~hyask/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/460766 -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~hyask/autopkgtest-cloud:skia/d-r_fix_locking into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/download-all-results b/charms/focal/autopkgtest-web/webcontrol/download-all-results index a3ae78d..1af7918 100755 --- a/charms/focal/autopkgtest-web/webcontrol/download-all-results +++ b/charms/focal/autopkgtest-web/webcontrol/download-all-results @@ -184,22 +184,25 @@ def fetch_one_result(url): while True: try: - c = db_con.cursor() - c.execute( - "INSERT INTO result VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", - ( - test_id, - run_id, - ver, - test_triggers, - duration, - exitcode, - requester, - ",".join(env_vars), - test_uuid, - ), - ) - db_con.commit() + with ( + db_con + ): # this starts a transaction, making sure we release the lock at the end + c = db_con.cursor() + c.execute( + "INSERT INTO result VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", + ( + test_id, + run_id, + ver, + test_triggers, + duration, + exitcode, + requester, + ",".join(env_vars), + test_uuid, + ), + ) + db_con.commit() break except sqlite3.OperationalError as e: if "database is locked" in str(e): diff --git a/charms/focal/autopkgtest-web/webcontrol/download-results b/charms/focal/autopkgtest-web/webcontrol/download-results index 356a2df..e71d4a0 100755 --- a/charms/focal/autopkgtest-web/webcontrol/download-results +++ b/charms/focal/autopkgtest-web/webcontrol/download-results @@ -86,22 +86,25 @@ def process_message(msg, db_con): while True: try: - c = db_con.cursor() - c.execute( - "INSERT INTO result VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", - ( - test_id, - run_id, - version, - triggers, - duration, - exitcode, - requester, - info.get("env", ""), - test_uuid, - ), - ) - db_con.commit() + with ( + db_con + ): # this starts a transaction, making sure we release the lock at the end + c = db_con.cursor() + c.execute( + "INSERT INTO result VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", + ( + test_id, + run_id, + version, + triggers, + duration, + exitcode, + requester, + info.get("env", ""), + test_uuid, + ), + ) + db_con.commit() break except sqlite3.OperationalError as e: if "database is locked" in str(e):
-- Mailing list: https://launchpad.net/~canonical-ubuntu-qa Post to : canonical-ubuntu-qa@lists.launchpad.net Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa More help : https://help.launchpad.net/ListHelp