rq / django-rq

A simple app that provides django integration for RQ (Redis Queue)
MIT License
1.81k stars 282 forks source link

ValueError: Invalid attribute name/AttributeError: module has no attribute #644

Open krlx opened 5 months ago

krlx commented 5 months ago
AttributeError: module 'scheduler.triggers' has no attribute ''

During handling of the above exception, another exception occurred:
Traceback (most recent call last):  
File "/venv/lib/python3.11/site-packages/rq/worker.py", line 1449, in perform_job    job.execute_failure_callback(self.death_penalty_class, *exc_info)  
File "/venv/lib/python3.11/site-packages/rq/job.py", line 1423, in execute_failure_callback    if not self.failure_callback:            
File "/venv/lib/python3.11/site-packages/rq/job.py", line 448, in failure_callback    self._failure_callback = import_attribute(self._failure_callback_name)                           
File "/venv/lib/python3.11/site-packages/rq/utils.py", line 120, in import_attribute    
raise ValueError('Invalid attribute name: %s' % attribute_name)
ValueError: Invalid attribute name: report_failure'

I'm using the command python manage.py rqscheduler. The command is executed from a location that can import report_failure from scheduler.triggers. The function report_failure is defined in the same file scheduler.triggers that also calls enqueue_at.

The same happens to me no matter if I pass the function itself (report_failure), or its whole path as a string ("scheduler.triggers.report_failure").

Versions:

django_rq-2.10.1
rq-1.15.1
rq_scheduler-0.13.1

Notes: This seems to happen randomly. Sometimes it works, some minutes later for the next scheduled job, I'm seeing this error. The same issue happens randomly when I use django_rq without rq_scheduler, starting it with: python manage.py rqworker --with-scheduler

Same issue opened in rq: https://github.com/rq/rq/issues/2035