🕌

Celeryの警告について

2024/09/10に公開

こんな警告が出る

[2024-09-10 10:38:14,420: WARNING/MainProcess] /Users/yoshi/hoge/venv/lib/python3.12/site-packages/celery/worker/consumer/consumer.py:508: CPendingDeprecationWarning: The broker_connection_retry configuration setting will no longer determine
whether broker connection retries are made during startup in Celery 6.0 and above.
If you wish to retain the existing behavior for retrying connections on startup,
you should set broker_connection_retry_on_startup to True.
  warnings.warn(

[2024-09-10 10:38:14,429: INFO/MainProcess] Connected to redis://localhost:6379/0

[2024-09-10 10:38:14,431: WARNING/MainProcess] /Users/yoshi/hoge/venv/lib/python3.12/site-packages/celery/worker/consumer/consumer.py:508: CPendingDeprecationWarning: The broker_connection_retry configuration setting will no longer determine
whether broker connection retries are made during startup in Celery 6.0 and above.
If you wish to retain the existing behavior for retrying connections on startup,
you should set broker_connection_retry_on_startup to True.
  warnings.warn(

対応:設定ファイルに追記する

ファイル探す(自担当であればすぐ見つかると思うのでいらないとは思う)

find . -name "celery.py"

追記

以下のような文言Celery.pyに追記する

# Celeryの設定を更新
app.conf.update(
    broker_connection_retry_on_startup=True  # ここに設定を追加
)

これで再起動すればOK

Discussion