Skip to content

Commit 2eaa872

Browse files
committed
asyncpg
1 parent f3761ae commit 2eaa872

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

services/storage/src/simcore_service_storage/simcore_s3_dsm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ async def abort_file_upload(
398398
await self._update_database_from_storage(fmd)
399399
except S3KeyNotFoundError:
400400
# the file does not exist, so we delete the entry in the db
401-
async with self.engine.connect() as conn:
401+
async with self.engine.begin() as conn:
402402
await db_file_meta_data.delete(conn, [fmd.file_id])
403403

404404
async def complete_file_upload(
@@ -555,7 +555,7 @@ async def delete_file(
555555
async def delete_project_simcore_s3(
556556
self, user_id: UserID, project_id: ProjectID, node_id: NodeID | None = None
557557
) -> None:
558-
async with self.engine.connect() as conn:
558+
async with self.engine.begin() as conn:
559559
can: AccessRights = await get_project_access_rights(
560560
conn, user_id, project_id
561561
)
@@ -780,7 +780,7 @@ async def create_soft_link(
780780
target.file_id = link_file_id # NOTE: api-server relies on this id
781781
target.is_soft_link = True
782782

783-
async with self.engine.connect() as conn:
783+
async with self.engine.begin() as conn:
784784
return convert_db_to_model(await db_file_meta_data.insert(conn, target))
785785

786786
async def _clean_pending_upload(
@@ -1041,7 +1041,7 @@ async def _copy_path_s3_s3(
10411041
bytes_transfered_cb=bytes_transfered_cb,
10421042
)
10431043
# we are done, let's update the copy with the src
1044-
async with self.engine.connect() as conn:
1044+
async with self.engine.begin() as conn:
10451045
updated_fmd = await self._update_fmd_from_other(
10461046
conn, fmd=new_fmd, copy_from=src_fmd
10471047
)

services/storage/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def project_slug_dir(osparc_simcore_root_dir: Path) -> Path:
115115
async def cleanup_user_projects_file_metadata(sqlalchemy_async_engine: AsyncEngine):
116116
yield
117117
# cleanup
118-
async with sqlalchemy_async_engine.connect() as conn:
118+
async with sqlalchemy_async_engine.begin() as conn:
119119
await conn.execute(file_meta_data.delete())
120120
await conn.execute(projects.delete())
121121
await conn.execute(users.delete())

services/storage/tests/unit/test_dsm_dsmcleaner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ async def test_clean_expired_uploads_reverts_to_last_known_version_expired_pendi
284284
)
285285

286286
# now change the upload_expires_at entry to simulate an expired entry
287-
async with sqlalchemy_async_engine.connect() as conn:
287+
async with sqlalchemy_async_engine.begin() as conn:
288288
await conn.execute(
289289
file_meta_data.update()
290290
.where(file_meta_data.c.file_id == file_id)
@@ -346,7 +346,7 @@ async def test_clean_expired_uploads_does_not_clean_multipart_upload_on_creation
346346
sha256_checksum=checksum,
347347
)
348348
# we create the entry in the db
349-
async with sqlalchemy_async_engine.connect() as conn:
349+
async with sqlalchemy_async_engine.begin() as conn:
350350
await db_file_meta_data.upsert(conn, fmd)
351351

352352
# ensure the database is correctly set up

services/storage/tests/unit/test_dsm_soft_links.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async def output_file(
4343
file.file_size = ByteSize(12)
4444
file.user_id = user_id
4545

46-
async with sqlalchemy_async_engine.connect() as conn:
46+
async with sqlalchemy_async_engine.begin() as conn:
4747
stmt = (
4848
file_meta_data.insert()
4949
.values(jsonable_encoder(FileMetaDataAtDB.model_validate(file)))

0 commit comments

Comments
 (0)