Using Celery and RabbitMQ with background callbacks

I am using Windows OS and am trying to integrate Celery (with RabbitMQ as the broker) with my Dash app. As a test, I have adapted the first Background Callback example provided on the Dash site, but I am having trouble getting it to work.

I have the following project structure:

test_celery/
__init__.py
celery_app.py
background_callback_example.py

celery_app.py

from __future__ import absolute_import
from celery import Celery
import os
         
celery_app = Celery('test_celery',
                     broker=os.environ['RABBITMQ'],
                     backend='rpc://',
                     include=['background_callback_example']
                     )

background_callback_example.py

import time
import os
from dash import Dash, DiskcacheManager, CeleryManager, Input, Output, html, callback
from celery_app import celery_app

background_callback_manager = CeleryManager(celery_app)

app = Dash(__name__)

app.layout = html.Div(
    [
        html.Div([html.P(id="paragraph_id", children=["Button not clicked"])]),
        html.Button(id="button_id", children="Run Job!"),
    ]
)

@callback(
    output=Output("paragraph_id", "children"),
    inputs=Input("button_id", "n_clicks"),
    background=True,
    manager=background_callback_manager,
)
def update_clicks(n_clicks):
    time.sleep(2.0)
    return [f"Clicked {n_clicks} times"]


if __name__ == "__main__":
    app.run(debug=True)

Packages:

Package Version


amqp 5.2.0
async-timeout 4.0.3
billiard 4.2.0
blinker 1.8.2
celery 5.4.0
certifi 2024.6.2
cffi 1.16.0
charset-normalizer 3.3.2
click 8.1.7
click-didyoumean 0.3.1
click-plugins 1.1.1
click-repl 0.3.0
colorama 0.4.6
dash 2.17.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table 5.0.0
dnspython 2.6.1
eventlet 0.36.1
Flask 3.0.3
flower 2.0.1
gevent 24.2.1
greenlet 3.0.3
humanize 4.9.0
idna 3.7
importlib_metadata 7.1.0
itsdangerous 2.2.0
Jinja2 3.1.4
kombu 5.3.7
MarkupSafe 2.1.5
nest-asyncio 1.6.0
packaging 24.0
pip 22.3.1
plotly 5.22.0
prometheus_client 0.20.0
prompt_toolkit 3.0.45
pycparser 2.22
python-dateutil 2.9.0.post0
pytz 2024.1
redis 5.0.4
requests 2.32.3
retrying 1.3.4
setuptools 65.5.0
six 1.16.0
tenacity 8.3.0
tornado 6.4
typing_extensions 4.12.1
tzdata 2024.1
urllib3 2.2.1
vine 5.1.0
wcwidth 0.2.13
Werkzeug 3.0.3
zipp 3.19.1
zope.event 5.0
zope.interface 6.4.post2

After I have launched RabbitMQ, I run the following command in the console which successfully launches Celery:

celery --app=celery_app worker --pool=threads --concurrency=8

However, when I run the background_callback_example.py script, the Dash app opens in the browser, but I receive these error messages:

AttributeError: 'RPCBackend' object has no attribute 'set'
[2024-06-03 14:34:56,060: INFO/MainProcess] Task long_callback_f13b1c8827174e79f63df6aca324b931944c67f3a7a2c1d94e4539067db87e6a[ab33fa60-d027-43a5-b00b-11ac5cdc6b15] received
[2024-06-03 14:34:58,077: ERROR/MainProcess] Task long_callback_f13b1c8827174e79f63df6aca324b931944c67f3a7a2c1d94e4539067db87e6a[ab33fa60-d027-43a5-b00b-11ac5cdc6b15] raised unexpected: AttributeError("'RPCBackend' object has no attribute 'set'")
Traceback (most recent call last):
  File "D:\Environments\test_celery_venv\Lib\site-packages\celery\app\trace.py", line 453, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "D:\Environments\test_celery_venv\Lib\site-packages\celery\app\trace.py", line 736, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Environments\test_celery_venv\Lib\site-packages\dash\long_callback\managers\celery_manager.py", line 196, in job_fn
    ctx.run(run)
  File "D:\Environments\test_celery_venv\Lib\site-packages\dash\long_callback\managers\celery_manager.py", line 192, in run
    cache.set(
    ^^^^^^^^^
AttributeError: 'RPCBackend' object has no attribute 'set'

Whenever I click the Run Job! button on the page I receive the same error messages.

I would appreciate any help or suggestions. Thanks!