django-rq: AttributeError: 'module' object has no attribute
I am trying to create a background job with 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'
I keep getting this error:
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
I also posted it to SO earlier http://stackoverflow.com/questions/32733934/rq-attributeerror-module-object-has-no-attribute
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 19
Adding a comment as I too ran into this error:
Rqworker does not dynamically reload when you change your code, but the Django dev webserver does So if you add/modify a task & immediately call it, you may run into this error as the new code (your web code) tries to call the old code (the RQ task).
Stop/restart rqworker and you’re ok.
_send_password_reset_email_async is local function inside function. Declare it on module level @krlx
Hi I’m having the same issue with this.
I’m trying to execute some rq tasks in views following below.
Sometimes the tasks is not executed properly in worker. Some task succeed and the rest failed. I expect those task are executed properly.
These are my
rqanddjango-rqversionsHere is the stacktrace from django rq admin