我有一个 celery 应用程序,我的文件如下:
/fetcher.py
/mirad
celery.py
fetcher_tasks.py
在celery.py
中我导入了fetcher_tasks.py
在 fetcher.py 中,我从 fetcher_tasks.py 调用一个任务
我想在 fetcher.py 中导入 celery.control
但我做不到,我该如何完成这项工作?
这是我的提取器代码的一部分:
from __future__ import absolute_import
import mirad.fetcher_tasks as tasks
from mirad.models.models import SourceModel
from mirad.settings import *
from mirad.celery.control import inspect
parse_feed_tasks = list()
def fetch():
for source in SourceModel.objects(active=True):
a = tasks.parse_feed.delay(source)
最佳答案
看起来您在项目中混合了 celery.py,该项目用于使用 celery 包启动 Celery 应用程序,您可以从中导入必要的函数。
您应该从 celery.task.control
包中导入 inspect
函数。
from __future__ import absolute_import
import mirad.fetcher_tasks as tasks
from mirad.models.models import SourceModel
from mirad.settings import *
from celery.task.control import inspect
parse_feed_tasks = list()
def fetch():
for source in SourceModel.objects(active=True):
a = tasks.parse_feed.delay(source)
关于python - 导入错误: No module named control,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24583373/