fastapi-alembic-sqlmodel-async
fastapi-alembic-sqlmodel-async copied to clipboard
Task completed but still shows pending
celery.conf.update({
"beat_dburi": settings.SYNC_CELERY_BEAT_DATABASE_URI,
'beat_schedule': {
'run-periodic-task-every-60-seconds': {
'task': 'tasks.periodic',
'schedule': timedelta(seconds=10),
},
}
})
async def get_hero(hero_id: UUID) -> list[HeroRead]:
async with SessionLocal() as session:
await asyncio.sleep(5)
hero = await crud.hero.get(id=hero_id, db_session=session)
return hero
@celery.task(name="tasks.periodic")
def periodic_task_example() -> None:
try:
hero = runnify(get_hero)(hero_id=UUID('b4cd39a6-0d89-44b6-b439-96a92a0fbdb6'))
return hero.id
except Exception as e:
print(e)
For the 1st time get data successfully. After then it shows Task <Task pending name='functools' coro=<run.
Hello @russell310 that is weird I am going to check it
Was this issue ever solved?
Hello @russell310 and @vcnwafor the bug was solved here https://github.com/jonra1993/fastapi-alembic-sqlmodel-async/issues/94. using asyncio.get_event_loop().run_until_complete() instead of runnify.