Skip to content

Commit 0378bdb

Browse files
committed
Update asyncio run async code in sync code
1 parent 3c173d5 commit 0378bdb

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

backend/app/app/api/celery_task.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from app.core.celery import celery
66
from app.models.hero_model import Hero
77
from app.db.session import SessionLocal
8-
from asyncer import runnify
98
import logging
109
from celery import Task
1110
from transformers import pipeline
@@ -67,6 +66,6 @@ async def get_hero(hero_id: UUID) -> Hero:
6766

6867

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

0 commit comments

Comments
 (0)