Search code examples
pythonasynchronousrabbitmqcelerycelery-task

Celery unregistered task KeyError


I start the worker by executing the following in the terminal:

celery -A cel_test  worker --loglevel=INFO --concurrency=10 -n worker1.%h

Then I get a long looping error message stating that celery has received an unregistered task and has triggered:

KeyError: 'cel_test.grp_all_w_codes.mk_dct' #this is the name of the task

The problem with this is that cel_test.grp_all_w_codes.mk_dct doesn't exist. In fact there isn't even a module cel_test.grp_all_w_codes let alone the task mk_dct. There was once a few days ago but I've since deleted it. I thought maybe there was a .pyc file floating around but there isn't. I also can't find a single reference in my code to the task that's throwing the error. I shut down my computer and restarted the rabbitmq server thinking maybe a reference to something was just stuck in memory but it did not help.

Does anyone have any idea what could be the problem here or what I'm missing?


Solution

  • Well, without knowing your conf files, I can see two reasons that would provoke this:

    • the mk_dct task wasn't completed when you stopped the worker and delete the module. If you're running with CELERY_ACKS_LATE, it will try to relaunch the task everytime you re run the worker. Try remove this setting, or launch the worker with the purge option.

    celery -A cel_test worker --loglevel=INFO --concurrency=10 -n worker1.%h --purge

    • the mk_dct task is launched by your celery beat. If so, try relaunching celery beat and clearing it's database backend if you had a custom one.

    If it does not solve the problem, please post your celery conf, and make sure you have cleaned all the .pyc of your project and restarted everything.