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."""