From d592eb153c2f84db957161b4602debf2d3944e46 Mon Sep 17 00:00:00 2001 From: bb Date: Tue, 28 Jul 2026 09:19:13 -0400 Subject: [PATCH] fix: db_execute lock scope to prevent thread-safety race (#1320) --- nxc/database.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nxc/database.py b/nxc/database.py index 382c1267..3c86ce35 100644 --- a/nxc/database.py +++ b/nxc/database.py @@ -204,10 +204,9 @@ class BaseDB: self.db_execute(table.delete()) def db_execute(self, *args): - self.lock.acquire() - res = self.sess.execute(*args) - self.lock.release() - return res + with self.lock: + res = self.sess.execute(*args) + return res.freeze()() if res.returns_rows else res def get_keys(self, key_id=None, cred_id=None): """Return an empty list by default. Protocols that support keys (e.g. SSH) override this."""