Skip to content

Commit

Permalink
Update asyncio run async code in sync code
Browse files Browse the repository at this point in the history
  • Loading branch information
jonra1993 committed Apr 1, 2024
1 parent 3c173d5 commit 0378bdb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions backend/app/app/api/celery_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from app.core.celery import celery
from app.models.hero_model import Hero
from app.db.session import SessionLocal
from asyncer import runnify
import logging
from celery import Task
from transformers import pipeline
Expand Down Expand Up @@ -67,6 +66,6 @@ async def get_hero(hero_id: UUID) -> Hero:


@celery.task(name="tasks.print_hero")
def print_hero(hero_id: UUID) -> None:
hero = runnify(get_hero)(hero_id=hero_id)
def print_hero(hero_id: UUID) -> None:
hero = asyncio.get_event_loop().run_until_complete(get_hero(hero_id=hero_id))
return hero.id

0 comments on commit 0378bdb

Please sign in to comment.