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

Queuing Python Static Methods. #60

Open
reversearrow opened this issue Apr 17, 2018 · 1 comment
Open

Queuing Python Static Methods. #60

reversearrow opened this issue Apr 17, 2018 · 1 comment

Comments

@reversearrow
Copy link

Hello,

I am looking to queue some of the Python @staticmethods. For some reason, I am getting following error when using Python RQ/ Flask-RQ2. Please help.

@staticmethod
@rq.job
def add_request(request):
    db.session.add(request)
    db.session.commit()

@staticmethod
@rq.job
def monitor_request(id):
    job = Job.fetch(id)
    accepted_statues = ['finished','failed']
    while job.status not in accepted_statues:
        time.sleep(1)
    request = Requests.query.filter_by(jobid=job.id).first()
    request.status = job.status
    db.session.add(request)
    db.session.commit()

15:30:06 AttributeError: 'module' object has no attribute 'add_request'
Traceback (most recent call last):
File "/home/PROD.CAN/rsojshah/netaut/lib/python2.7/site-packages/rq/worker.py", line 789, in perform_job
rv = job.perform()
File "/home/PROD.CAN/rsojshah/netaut/lib/python2.7/site-packages/rq/job.py", line 573, in perform
self._result = self._execute()
File "/home/PROD.CAN/rsojshah/netaut/lib/python2.7/site-packages/rq/job.py", line 579, in _execute
return self.func(*self.args, **self.kwargs)
File "/home/PROD.CAN/rsojshah/netaut/lib/python2.7/site-packages/rq/job.py", line 206, in func
return import_attribute(self.func_name)
File "/home/PROD.CAN/rsojshah/netaut/lib/python2.7/site-packages/rq/utils.py", line 153, in import_attribute
return getattr(module, attribute)
AttributeError: 'module' object has no attribute 'add_request'
Traceback (most recent call last):
File "/home/PROD.CAN/rsojshah/netaut/lib/python2.7/site-packages/rq/worker.py", line 789, in perform_job
rv = job.perform()
File "/home/PROD.CAN/rsojshah/netaut/lib/python2.7/site-packages/rq/job.py", line 573, in perform
self._result = self._execute()
File "/home/PROD.CAN/rsojshah/netaut/lib/python2.7/site-packages/rq/job.py", line 579, in _execute
return self.func(*self.args, **self.kwargs)
File "/home/PROD.CAN/rsojshah/netaut/lib/python2.7/site-packages/rq/job.py", line 206, in func
return import_attribute(self.func_name)
File "/home/PROD.CAN/rsojshah/netaut/lib/python2.7/site-packages/rq/utils.py", line 153, in import_attribute
return getattr(module, attribute)
AttributeError: 'module' object has no attribute 'add_request'
15:30:06 Moving job to u'failed' queue

@jezdez
Copy link
Member

jezdez commented Sep 19, 2018

Please provide the whole code example including the class declaration of the static methods.

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

2 participants