diff --git a/src/indexers/immunefi.py b/src/indexers/immunefi.py index 09d8e3e..c7cf430 100644 --- a/src/indexers/immunefi.py +++ b/src/indexers/immunefi.py @@ -515,7 +515,12 @@ async def download_assets(self, project_id: int, asset_data): # noqa: C901 ) self.session.add(new_asset) - await self.session.commit() + # Fix the commit logic to handle both sync and async sessions + if hasattr(self.session, "commit"): + if asyncio.iscoroutinefunction(self.session.commit): + await self.session.commit() + else: + self.session.commit() if not self.initialize_mode: await self.trigger_event(HandlerTrigger.NEW_ASSET, {"asset": new_asset}) @@ -654,7 +659,12 @@ async def download_assets(self, project_id: int, asset_data): # noqa: C901 ) self.session.add(new_asset) - await self.session.commit() + # Fix the commit logic to handle both sync and async sessions + if hasattr(self.session, "commit"): + if asyncio.iscoroutinefunction(self.session.commit): + await self.session.commit() + else: + self.session.commit() if not self.initialize_mode: await self.trigger_event(HandlerTrigger.NEW_ASSET, {"asset": new_asset})