Skip to content

Commit fd24e7b

Browse files
committed
close sqlite connection
1 parent 1a9811e commit fd24e7b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

synapseclient/models/services/migration_types.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ def get_counts_by_status(self) -> Dict[str, int]:
196196
"""
197197
import sqlite3
198198

199-
with sqlite3.connect(self.db_path) as conn:
199+
conn = sqlite3.connect(self.db_path)
200+
try:
200201
cursor = conn.cursor()
201202

202203
# Only count FILE and TABLE_ATTACHED_FILE entries
@@ -213,6 +214,8 @@ def get_counts_by_status(self) -> Dict[str, int]:
213214
counts[MigrationStatus(status_value).name] = count
214215

215216
return counts
217+
finally:
218+
conn.close()
216219

217220
async def get_counts_by_status_async(self) -> Dict[str, int]:
218221
"""Get counts by migration status (asynchronous).
@@ -232,7 +235,8 @@ def get_migrations(self) -> Iterator[Dict[str, Any]]:
232235
"""
233236
import sqlite3
234237

235-
with sqlite3.connect(self.db_path) as conn:
238+
conn = sqlite3.connect(self.db_path)
239+
try:
236240
cursor = conn.cursor()
237241

238242
batch_size = 500
@@ -306,6 +310,8 @@ def get_migrations(self) -> Iterator[Dict[str, Any]]:
306310
"status": MigrationStatus(row[10]).name,
307311
"exception": row[11],
308312
}
313+
finally:
314+
conn.close()
309315

310316
async def get_migrations_async(self) -> List[Dict[str, Any]]:
311317
"""Get all migration entries (asynchronous).

0 commit comments

Comments
 (0)