LoginSignup
1
1

More than 3 years have passed since last update.

Celery4.3.0でresult_expiresを正しく適用する

Posted at

tl;dr

Celeryのドキュメントが間違っていた。

背景

DjangoでCeleryを使う際に、Result BackendにRedisを指定して動かしたとき、どうもresult_expiresの設定がうまくいかなかった。

やりたいこと

result_expiresを正しく設定する。

環境

  • Celery 4.3.0
  • Django 2.2.6
  • Redis 5.0.1

やること

CELERY_TASK_RESULT_EXPIRES ではなく CELERY_RESULT_EXPIRES で設定する。

settings.py
# CELERY_TASK_RESULT_EXPIRES = 3600
CELERY_RESULT_EXPIRES = 3600

秒単位なので、これで期限を1時間に設定されます。

補足

PR投げるチャンスかと思いましたが、既に対応済みでした。

https://github.com/celery/celery/issues/5473
https://github.com/celery/celery/pull/5475

4.4.0リリース後に反映されるようで、現状(2019/10/09)のドキュメントは修正されていません。
というのもあって、この記事を書きました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1