Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task completed but still shows pending #89

Closed
russell310 opened this issue Nov 4, 2023 · 3 comments
Closed

Task completed but still shows pending #89

russell310 opened this issue Nov 4, 2023 · 3 comments

Comments

@russell310
Copy link

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..wrapper()> How to solve this issue?

@jonra1993
Copy link
Owner

Hello @russell310 that is weird I am going to check it

@jonra1993 jonra1993 pinned this issue Nov 14, 2023
@vcnwafor
Copy link

vcnwafor commented Feb 3, 2024

Was this issue ever solved?

@jonra1993
Copy link
Owner

jonra1993 commented Apr 1, 2024

Hello @russell310 and @vcnwafor the bug was solved here #94. using asyncio.get_event_loop().run_until_complete() instead of runnify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants