Skip to content

Commit bcae0b9

Browse files
committed
Fix locking acquisition and release
1 parent 92a9d65 commit bcae0b9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

reframe/frontend/reporting/storage.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# SPDX-License-Identifier: BSD-3-Clause
55

66
import abc
7+
import contextlib
78
import functools
89
import json
910
import os
@@ -126,13 +127,17 @@ def _db_connect(self, *args, **kwargs):
126127
with getprofiler().time_region('sqlite connect'):
127128
return sqlite3.connect(*args, **kwargs)
128129

130+
@contextlib.contextmanager
129131
def _db_read(self, *args, **kwargs):
130132
with self.__db_lock.read_lock():
131-
return self._db_connect(*args, **kwargs)
133+
with self._db_connect(*args, **kwargs) as conn:
134+
yield conn
132135

136+
@contextlib.contextmanager
133137
def _db_write(self, *args, **kwargs):
134138
with self.__db_lock.write_lock():
135-
return self._db_connect(*args, **kwargs)
139+
with self._db_connect(*args, **kwargs) as conn:
140+
yield conn
136141

137142
def _db_create(self):
138143
clsname = type(self).__name__

0 commit comments

Comments
 (0)