Forums

My two alwayson-tasks are combined and don't work well

A year ago I created an always-on-task for the only web app I had using Celery and running their respective self-recognizing tasks. Now I have 2 web apps and for each one I have created an always-on-task (task1 and task2) but I have noticed in the logs that when I want task2 to be executed it does not work because task1 tries to execute the subtask and it does not exist in it throwing the error:

Aug 30 12:19:46 [2023-08-30 08:19:46,827: ERROR/MainProcess] Received unregistered task of type 'crm.tasks.task_create_lead'.
Aug 30 12:19:46 The message has been ignored and discarded.
Aug 30 12:19:46 Did you remember to import the module containing this task?
Aug 30 12:19:46 Or maybe you're using relative imports?
Aug 30 12:19:46 Please see
Aug 30 12:19:46 http://docs.celeryq.org/en/latest/internals/protocol.html
Aug 30 12:19:46 for more information.
Aug 30 12:19:46 The full contents of the message body was:
Aug 30 12:19:46 b'[[12], {}, {"callbacks": null, "errbacks": null, "chain": null, "chord": null}]' (79b)
Aug 30 12:19:46 Traceback (most recent call last):
Aug 30 12:19:46   File "/home/smarthomy/.virtualenvs/shaas_smarthomy/lib/python3.8/site-packages/celery/worker/consumer/consumer.py", line 581, in on_task_received
Aug 30 12:19:46     strategy = strategies[type_]
Aug 30 12:19:46 KeyError: 'crm.tasks.task_create_lead'

Why are they mixed? thanks for your help

That looks like you need to have some way of determining which task is supposed to be run by which task runner.