Flower can't see tasks created by Celery signals
This has been an issue for all of our projects for three years, but I've finally decided to write about it. It's more of a visual inconvenience.
Our projects have the same setup of: Django - Celery - Redis - Flower.
Celery is run with
/bin/sh -c /home/django/.local/bin/celery multi start worker1 -A project --pidfile=/home/django/celery/%n.pid --concurrency=5 --logfile=/home/django/celery/%n%I.log --loglevel=DEBUG
Flower is run with
/bin/python /home/django/.local/bin/celery -A project flower --port=8787 --log-file-prefix=/home/django/celery/flower.log --loglevel=DEBUG
Broker string: redis://127.0.0.1:6379/0
celery.py:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
app: Celery = Celery('project')
app.config_from_object(settings, namespace='CELERY')
app.autodiscover_tasks()
If a background function is created through Celery's .delay(), it shows up in Flower just fine. But if it's called from within a Signal (ex. inside a function with @worker_ready.connect or through a app.conf.beat_schedule config), it does not show up in Flower's dashboard.
- My background tasks run just fine, so I doubt it's Django's problem.
- My background tasks can print themselves with @app.task(bind=True) and are visible with app.control.inspect().active(), so I doubt it's Celery's problem.
- redis-cli MONITOR shows that Redis is receiving tasks, so I doubt it's Redis's problem.
- I can see IDs of my background tasks in Flower's "Workers - Worker - Tasks - Active tasks" tab. The IDs are consistent with previous steps...
- But when I click on any of them (of signal-created), the web says: "Unknown task 'id'" The global list of tasks also says "No data available in table" (unless there were non-signal-created tasks).
- But most curiously, if I kill Celery process, now Flower can see those tasks, which are marked as Failed by raising
celery.exceptions.WorkerShutdown: 0
billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 15 (SIGTERM) Job: 1
So this tells me that Flower can see them, but decides to not display them for whatever reason.
I've looked at what Celery Worker is receiving, and both normal and invisible background tasks look identical aside of IDs, which as far as I can tell matches with what Redis is getting. Meaning that functionally, there should be no difference with how the task is created..
TaskPool: Apply < function fast_trace_task at 0x7f243de709d0 > (
args: ('... .background_task', '8c68b20f-d5b4-4c56-823d-892783a0dd83', {
'lang': 'py',
'task': '... .background_task',
'id': '8c68b20f-d5b4-4c56-823d-892783a0dd83',
'shadow': None,
'eta': None,
'expires': None,
'group': None,
'group_index': None,
'retries': 0,
'timelimit': [None, None],
'root_id': '8c68b20f-d5b4-4c56-823d-892783a0dd83',
'parent_id': None,
'argsrepr': '()',
'kwargsrepr': '{}',
'origin': 'gen1460173@hostname',
'ignore_result': False,
'replaced_task_nesting': 0,
'stamped_headers': None,
'stamps': {},
'properties': {
'correlation_id': '8c68b20f-d5b4-4c56-823d-892783a0dd83',
'reply_to': 'e5baa096-2704-3459-9c6b-6dd75c07f1a3',
'delivery_mode': 2,
'delivery_info': {
'exchange': '',
'routing_key': 'celery'
},
'priority': 0,
'body_encoding': 'base64',
'delivery_tag': '7075234a-bbae-442a-95fb-38d5f6ef9f2e'
},
'reply_to': 'e5baa096-2704-3459-9c6b-6dd75c07f1a3',
'correlation_id': '8c68b20f-d5b4-4c56-823d-892783a0dd83',
'hostname': 'worker1@hostname',
'delivery_info': {
'exchange': '',
...kwargs: {})
Would appreciate some suggestions, because not seeing background tasks in a web client for viewing background tasks is pretty weird.
Just curious here @Amonimus - are you viewing flower's web UI behind a reverse proxy of any kind? Have you watched the browser inspect console while clicking to see if 401/404s are showing (beyond the *.map file which won't affect runtime)?
Could be a url_prefix path issue, if you are.
Just curious here @Amonimus - are you viewing flower's web UI behind a reverse proxy of any kind? Have you watched the browser inspect console while clicking to see if 401/404s are showing (beyond the *.map file which won't affect runtime)?
Could be a url_prefix path issue, if you are.
- Don't think so, and I've shut down Nginx to be sure. I'm accessing Flower in the web browser using http://machine'sIP:8787 as the address, so the Flower process must be serving it directly. Even if there was a proxy, it'd be odd that only specific tasks are glitched.
- Such tasks trigger a 404 status in the console, which isn't surprizing if they can't be opened. Implying Flower lists them on the worker's tab anyway, but somehow can't access them.
Currently checked on setups:
- Python 3.8.20 Mar 26 2025 (can't test a fresher version atm, and as noted I recall seeing this behavior in 2023 but kept disregarding it)
- Celery 5.4.0
- Flower 2.0.1
- Redis 8.2.1 (5.2.1 py module)
- Django 4.2.20 ,
- Python 3.8.20 Mar 26 2025
- Celery 4.4.2
- Flower 0.9.4
- Redis 8.2.1 (5.0.1 py module)
- Django 3.0.5 and they act identically for autostarted tasks.