AttributeError: module 'celery' has no attribute 'Router'
AttributeError: module 'celery' has no attribute 'Router'
我使用 OpenedX Koa-1.0。当我尝试发送批量电子邮件时,Celery 会引发此错误。
有日志:
2021-04-08 12:19:46,189 ERROR 7630 [celery.app.trace] [user None] [ip None] trace.py:255 - Task lms.djangoapps.instructor_task.tasks.send_bulk_course_email[6781e01e-7197-4f29-91ed-e374e3b90945] raised unexpected: AttributeError("module 'celery' has no attribute 'Router'")
Traceback (most recent call last):
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/trace.py", line 412, in trace_task
R = retval = fun(*args, **kwargs)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/trace.py", line 704, in protected_call
return self.run(*args, **kwargs)
File "/opt/bitnami/apps/edx/edx-platform/lms/djangoapps/instructor_task/tasks.py", line 159, in send_bulk_course_email
return run_main_task(entry_id, visit_fcn, action_name)
File "/opt/bitnami/apps/edx/edx-platform/lms/djangoapps/instructor_task/tasks_helper/runner.py", line 120, in run_main_task
task_progress = task_fcn(entry_id, course_id, task_input, action_name)
File "/opt/bitnami/apps/edx/edx-platform/lms/djangoapps/bulk_email/tasks.py", line 224, in perform_delegate_email_batches
progress = queue_subtasks_for_query(
File "/opt/bitnami/apps/edx/edx-platform/lms/djangoapps/instructor_task/subtasks.py", line 350, in queue_subtasks_for_query
new_subtask.apply_async()
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/canvas.py", line 235, in apply_async
return _apply(args, kwargs, **options)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/task.py", line 566, in apply_async
return app.send_task(
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/base.py", line 708, in send_task
options = router.route(
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/routes.py", line 85, in route
route = self.lookup_route(name, args, kwargs, options, task_type)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/routes.py", line 117, in lookup_route
route = query(router, name, args, kwargs, options, task_type)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/routes.py", line 122, in query_router
router = maybe_evaluate(router)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/kombu/utils/functional.py", line 246, in maybe_evaluate
return value.evaluate()
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/utils/functional.py", line 51, in evaluate
self._value = super(mlazy, self).evaluate()
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/kombu/utils/functional.py", line 213, in evaluate
return self.fun(*self.args, **self._kwargs)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/routes.py", line 130, in expand_router_string
router = symbol_by_name(router)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/kombu/utils/imports.py", line 62, in symbol_by_name
return getattr(module, cls_name) if cls_name else module
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/local.py", line 517, in getattr
return ModuleType.getattribute(self, name)
AttributeError: module 'celery' has no attribute 'Router'
我尝试在 edxapp_env 中通过 pip 重新安装 Celery,但它不起作用。
也许有办法在芹菜中导入这个?或者将 celery/app/routes.py 移动到其他地方?
您可能所有设置都很好,但 运行 配置错误。这个例外有点误导:实际上,它意味着 settings.CELERY_ROUTES
没有设置。对于 Koa 版本,您可以使用的路由器是 lms.celery.Router
.
我使用 OpenedX Koa-1.0。当我尝试发送批量电子邮件时,Celery 会引发此错误。 有日志:
2021-04-08 12:19:46,189 ERROR 7630 [celery.app.trace] [user None] [ip None] trace.py:255 - Task lms.djangoapps.instructor_task.tasks.send_bulk_course_email[6781e01e-7197-4f29-91ed-e374e3b90945] raised unexpected: AttributeError("module 'celery' has no attribute 'Router'")
Traceback (most recent call last):
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/trace.py", line 412, in trace_task
R = retval = fun(*args, **kwargs)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/trace.py", line 704, in protected_call
return self.run(*args, **kwargs)
File "/opt/bitnami/apps/edx/edx-platform/lms/djangoapps/instructor_task/tasks.py", line 159, in send_bulk_course_email
return run_main_task(entry_id, visit_fcn, action_name)
File "/opt/bitnami/apps/edx/edx-platform/lms/djangoapps/instructor_task/tasks_helper/runner.py", line 120, in run_main_task
task_progress = task_fcn(entry_id, course_id, task_input, action_name)
File "/opt/bitnami/apps/edx/edx-platform/lms/djangoapps/bulk_email/tasks.py", line 224, in perform_delegate_email_batches
progress = queue_subtasks_for_query(
File "/opt/bitnami/apps/edx/edx-platform/lms/djangoapps/instructor_task/subtasks.py", line 350, in queue_subtasks_for_query
new_subtask.apply_async()
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/canvas.py", line 235, in apply_async
return _apply(args, kwargs, **options)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/task.py", line 566, in apply_async
return app.send_task(
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/base.py", line 708, in send_task
options = router.route(
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/routes.py", line 85, in route
route = self.lookup_route(name, args, kwargs, options, task_type)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/routes.py", line 117, in lookup_route
route = query(router, name, args, kwargs, options, task_type)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/routes.py", line 122, in query_router
router = maybe_evaluate(router)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/kombu/utils/functional.py", line 246, in maybe_evaluate
return value.evaluate()
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/utils/functional.py", line 51, in evaluate
self._value = super(mlazy, self).evaluate()
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/kombu/utils/functional.py", line 213, in evaluate
return self.fun(*self.args, **self._kwargs)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/app/routes.py", line 130, in expand_router_string
router = symbol_by_name(router)
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/kombu/utils/imports.py", line 62, in symbol_by_name
return getattr(module, cls_name) if cls_name else module
File "/opt/bitnami/apps/edx/venvs/edxapp/lib/python3.8/site-packages/celery/local.py", line 517, in getattr
return ModuleType.getattribute(self, name)
AttributeError: module 'celery' has no attribute 'Router'
我尝试在 edxapp_env 中通过 pip 重新安装 Celery,但它不起作用。 也许有办法在芹菜中导入这个?或者将 celery/app/routes.py 移动到其他地方?
您可能所有设置都很好,但 运行 配置错误。这个例外有点误导:实际上,它意味着 settings.CELERY_ROUTES
没有设置。对于 Koa 版本,您可以使用的路由器是 lms.celery.Router
.