Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Invalid attribute name for job callback #2035

Open
krlx opened this issue Feb 3, 2024 · 3 comments
Open

ValueError: Invalid attribute name for job callback #2035

krlx opened this issue Feb 3, 2024 · 3 comments

Comments

@krlx
Copy link

krlx commented Feb 3, 2024

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

@stelmath
Copy link

Same here

@hexkey
Copy link

hexkey commented May 28, 2024

same issue, without django, on flask. Unable to import function to run as job with same error

rq-worker      |   File "/usr/local/lib/python3.12/site-packages/rq/utils.py", line 109, in import_attribute
rq-worker      |     raise ValueError('Invalid attribute name: %s' % name)

Flask==3.0.3
rq==1.16.2
rq-scheduler==0.13.1

@hexkey
Copy link

hexkey commented May 28, 2024

it seems that this solves the issue but it's not mentioned as requirement, worker instance has to have app location added to PYTHONPATH ie:

export PYTHONPATH="$PYTHONPATH:/app/code"

or in case of docker:

ENV PYTHONPATH="$PYTHONPATH:/app/code"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants