Python Huey抛出Huey.exceptions.HueyException:xxxxxx未在TaskRegistry中找到

2024-06-01 00:26:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将Huey与Django集成在一起,在那里我几乎完成了应用程序的初始设置,以及所有与redis的集成。现在,当我运行实际的.py文件时,我得到一个异常huey.exceptions.HueyException:xxxxxxx未在TaskRegistry中找到。我遵循了here中提到的所有步骤,但到目前为止仍然没有运气。有没有人能帮我解释一下我遗漏了什么或者是有什么不对劲。提前谢谢

以下是我的代码和应用程序设置:

schedule_task.py

Task schedule code

settings.py

enter image description here

Command which I'm using to run the schedule_task.py

python manage.py shell < hueyTasks/schedule_task.py

Redis running on my local enter image description here

python manage.py run_huey command to run the consumer enter image description here


Tags: 文件thetodjangorunpyredis应用程序
1条回答
网友
1楼 · 发布于 2024-06-01 00:26:38

您的消费者找不到您的任务。假设您已将'huey.contrib.djhuey'添加到settings.py{a1}中的INSTALLED_APPS,可能的问题是您已将包含文件的任务命名为tasks.py以外的文件,这是Huey的Django集成自动发现所依赖的:

To run the consumer, use the run_huey management command. This command will automatically import any modules in your INSTALLED_APPS named tasks.py. The consumer can be configured using both the django settings module and/or by specifying options from the command-line.

或者,您可以避开自动发现功能,但是您必须稍微重新构造代码。详情见docs。我的建议是,您只需重命名文件tasks.py

相关问题 更多 >