gpt4 book ai didi

python - RQ 属性错误 : 'module' object has no attribute

转载 作者:太空宇宙 更新时间:2023-11-04 08:05:00 34 4
gpt4 key购买 nike

我正在尝试使用 RQ 创建后台作业:

import django_rq                                                         


def _send_password_reset_email_async(email):
print(email)

# Django admin action to send reset password emails
def send_password_reset_email(modeladmin, request, queryset):
for user in queryset:
django_rq.enqueue(_send_password_reset_email_async, user.email)
send_password_reset_email.short_description = 'Send password reset email'

虽然我一直收到此错误,但似乎我在做一些愚蠢的事情?

Traceback (most recent call last):
File "/home/lee/Code/cas/venv/lib/python3.4/site-packages/rq/worker.py", line 568, in perform_job
rv = job.perform()
File "/home/lee/Code/cas/venv/lib/python3.4/site-packages/rq/job.py", line

495, in perform
self._result = self.func(*self.args, **self.kwargs)
File "/home/lee/Code/cas/venv/lib/python3.4/site-packages/rq/job.py", line 206, in func
return import_attribute(self.func_name)
File "/home/lee/Code/cas/venv/lib/python3.4/site-packages/rq/utils.py", line 151, in import_attribute
return getattr(module, attribute)
AttributeError: 'module' object has no attribute '_send_password_reset_email_async

'

最佳答案

添加评论,因为我也遇到了这个错误:

当您更改代码时,Django 开发网络服务器会动态重新加载,但 rqworker 进程不会。因此,如果您添加/修改任务并立即调用它,您可能会遇到此错误,因为新代码(您的网络代码)试图调用旧代码(RQ 任务)。

停止/重启 rqworker 就可以了。

关于python - RQ 属性错误 : 'module' object has no attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32733934/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com