我正在使用烧杯缓存来缓存函数的输出。
当我使烧瓶 uwsgi 应用程序的缓存无效时,它没有反映在 celery 应用程序中,反之亦然。
进一步调查发现烧杯使用inspect.getsourcefile(func)
唯一密钥存储在redis中。
现在的问题是:在烧瓶 uwsgi 应用程序中,加载函数的路径显示为
./myproject/db_api.py
而在芹菜中它显示为:
/opt/myproject/db_api.py。
如何确保inspect.getsourcefile(func)
函数在两种情况下都返回相同的路径?
让 celery 将路径设置为 ./myporject/db_api.py 或烧瓶加载路径为 /opt/myproject/db_api.py 都可以。
Celery 正在/etc/default/celeryd 中作为守护进程运行。CELERYD_CHDIR='/opt'
在celeryconfig.py
我有CELERY_IMPORTS = ('myproject.controllers.celerytasks.cache_invalidate')
Flask 由 uwsig 在 ubuntu 上使用 .ini 文件运行,配置如下:
[uwsgi]
module = myproject
callable = app
chdir = /opt