0
votes

My original problem is that when running celery worker with --detach flag, or using celery multi, my application tasks are not registered with the workers ( although the workers do startup and are reachable, same is this question ). To help debug this problem I have made a plain celery app, which has a different but maybe related issue.

Source structure

setup.py
example
    | tasks.py
    | celery.py
    | __init__.py
    | __main__.py

tasks.py:

from example.celery import app

@app.task
def add(x, y):
    return x + y

celery.py

from celery import Celery

app = Celery('tasks', broker='redis://localhost:6379', include=["example.tasks"])

init.py

__version__ = "0.0.1"
__package__ = "example"

from example.celery import app

setup.py

from setuptools import setup
import example

setup(
    name=example.__package__,
    version=example.__version__,
    include_package_data=True,
    python_requires=">=3.7",
)

Install the package using $ pip install -e .

From anywhere in the system I can now run $ celery -A example worker

And I will have a worker with the add task. Adding --detach flag like this: $ celery -A example.celery.app worker --detach --logfile=$HOME/celery.log

Will give an error trying to connect to AMQPLAIN into the celery.log file, when the app is configured to use Redis:

...
amqp.exceptions.AccessRefused: (0, 0): (403) ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For details see the broker logfile.

So my understanding is that something is going off when the worker tries to load the celery app in detach mode, but I can't figure out what. Any assistance is greatly appreciated.

Using celery==4.4.7

Update This works with celery 5.0.2, will be opening a bug ticket.

1
Erm... celery -A example worker is different from celery -A example.celery.app worker, right?DejanLekic
I don't think so, my understanding is that celery will search for an app inside 'example', by passing the full path there is just less to search for. I have tried both approachesGiannis
In that case, the reason why it was failing is most likely PYTHONPATH ... Export PYTHONPATH=<directory containing example> and run the thing again.DejanLekic
"example" is installed globally. This is working with latest celery, so it may be a bugGiannis

1 Answers

0
votes