Skip to content

Commit

Permalink
Fix another indexer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
muellerberndt committed Jan 13, 2025
1 parent f6975ba commit 8353661
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/indexers/immunefi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit 8353661

Please sign in to comment.