File tree Expand file tree Collapse file tree
synapseclient/models/services Expand file tree Collapse file tree Original file line number Diff line number Diff 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).
You can’t perform that action at this time.
0 commit comments