问题描述
这是一个小故事...
That's a small story...
我遇到了这个错误:
当更改的tasks.py时,就像Diederik在
When changed tasks.py, like Diederik said at Celery with RabbitMQ: AttributeError: 'DisabledBackend' object has no attribute '_get_task_meta_for'
app = Celery('tasks', backend='rpc://', broker='amqp://guest@localhost//')
运行它
>>> from tasks import add
>>> result = add.delay(4,50)
>>> result.ready()
再次获得DisabledBackend ......嗯那是什么..
got DisabledBackend again ... hmm what was that..
将代码放入文件run.py并返回True ...
put code to file run.py and it returned True...
from tasks import add
try:
result = add.delay(1,4)
print (result.ready())
except:
print "exept"
我看到如果我在任务导入后调用>>>,在tasks.py发生变化之后添加,它就不会得到更新... ipython的行为是一样的,所以因为我无法理解原因,我建议人们从像~runthis.py这样的脚本调用DEBUG
I see that if I call >>> from tasks import add after tasks.py changed, it doesn't get the updates... That behaviour is the same for ipython, so because of I can't understand the reason, I advice people to DEBUG from scripts like ~runthis.py
很高兴答案会破坏我的想法...
Will be glad for answer which will smash my idea...
推荐答案
如果使用解释器,你需要
If using the interpreter, you need to
reload(tasks)
这会强制重新导入任务模块
this will force reimport tasks module
这篇关于需要在应用Celery配置时重启python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!