My current program setup consists of a run.py file with the following contents:
from cocapi.task import my_add
from cocapi import app
print(app.tasks.keys())
res = my_add.delay(1, 2)
print(res.get())
I then have a directory called cocapi, the contents of the __init__.py file are shown below:
from celery import Celery
app = Celery('cocapi')
app.config_from_object('cocapi.celeryconfig')
The task.py file can be found in the module directory with the following contents:
from cocapi import app
@app.task
def my_add(a, b):
return a + b
Upon running the run.py file I get the following error:
celery.exceptions.NotRegistered: 'cocapi.task.my_add'
However, the print statement from the run.py file is showing that the task had been added to the application:
dict_keys(['celery.chord_unlock', 'celery.group', 'celery.map', 'cocapi.task.my_add', 'celery.chain', 'celery.starmap', 'celery.accumulate', 'celery.chord', 'celery.backend_cleanup', 'celery.chunks'])
Additionally, I start up a RabbitMQ worker using the following command:
celery -A cocapi worker --loglevel=info
What could be going wrong here? Thanks for any help that you can provide me!