[Python] Celery raises `ValueError: not enough values to unpack (expected 3, got 0)` when...

Discussão em 'Python' iniciado por Stack, Abril 21, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using Celery in a Django project to schedule notification tasks. When I start the Celery worker and the task runs, I get the following error:

    ValueError: not enough values to unpack (expected 3, got 0)


    Full traceback:

    File "celery\app\trace.py", line 640, in fast_trace_task
    tasks, accept, hostname = _loc
    ValueError: not enough values to unpack (expected 3, got 0)


    This happens when the following task is triggered:

    # core/tasks.py

    from celery import shared_task
    from django.utils import timezone
    from core.models import Notification

    @shared_task
    def send_scheduled_notifications():
    now = timezone.now()
    notifications = Notification.objects.filter(
    is_read=False,
    send_at__lte=now
    )
    for notification in notifications:
    print(f"Sending notification: {notification.title}")
    notification.is_read = True
    notification.save()


    Celery starts successfully and logs the task as received, but then immediately crashes with the error above.

    My environment:

    • Windows 11
    • Python 3.13
    • Celery 5.5.1
    • Redis running locally

    I’ve confirmed the task runs fine when executed manually outside Celery.


    "I came across this similar question, but my error occurs in a different version of Celery and the task seems structured correctly."
    ​

    Continue reading...

Compartilhe esta Página