mattupstate / flask-rq Goto Github PK
View Code? Open in Web Editor NEWRQ (Redis Queue) integration for Flask applications
License: MIT License
RQ (Redis Queue) integration for Flask applications
License: MIT License
Are there any plans to migrate to/support python 3?
I have noticed that flask-rq does not use context-locals to save the redis connection, which means that everytime one request comes in, we are having a new connection.
What I need here is one connection manager so I do not have to handle connections myself.
Any reasons? So flask-rq is just a config manager? I do not see anything else meaningful here.
@mattupstate friendly ping whether there this project is still active. I've seen several issues without response and the last commit is from > 1yr ago. Discussing the best implementation of RQ with flask in rq/rq#538.
I've been getting these errors in my code trying to get this plugin to work. Then I tried on your examples and I'm running into the same issue.
(env)nuke@arch (~/flask-rq/example)[master*] $: python run.py
Traceback (most recent call last):
File "run.py", line 6, in <module>
from app import app
File "/home/nuke/flask-rq/example/app.py", line 21, in <module>
@rq.job
AttributeError: 'RQ' object has no attribute 'job'
(env)nuke@arch (~/flask-rq/example)[master*] $: python app.py
Traceback (most recent call last):
File "app.py", line 21, in <module>
@rq.job
AttributeError: 'RQ' object has no attribute 'job'
Hello, Senior engineer.I got a problem that I could not handle my task when I put the put the job into the queue.
The code is as following:
import time
from flask import Flask
from flask_rq2 import RQ
app = Flask(__name__)
app.debug = True
app.config['RQ_OTHER_HOST'] = 'localhost'
app.config['RQ_OTHER_PORT'] = 6379
app.config['RQ_OTHER_PASSWORD'] = None
app.config['RQ_OTHER_DB'] = 0
rq = RQ(app)
@app.route('/doit2')
def doit2():
echo = rq.get_queue().enqueue(takes_a_while, 'do it 2',
name="low", connection="other")
return 'Success2'
@app.route('/doit7')
def doit7():
echo = rq.get_worker('low').work(True)
print(echo)
return 'Success7'
Web Server got a wrong when I request the http://127.0.0.1:5000/doit7
:
ERRORS
๏ผ
File "E:\envs\lingang-newapi\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "E:\envs\lingang-newapi\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "E:\envs\lingang-newapi\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "E:\envs\lingang-newapi\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "E:\pythonProjects\DeCheng\module_exercise\flask-rq\my_example\example\app.py", line 101, in doit7
echo = rq.get_worker().work(True)
File "E:\envs\lingang-newapi\lib\site-packages\rq\worker.py", line 526, in work
self._install_signal_handlers()
File "E:\envs\lingang-newapi\lib\site-packages\rq\worker.py", line 389, in _install_signal_handlers
signal.signal(signal.SIGINT, self.request_stop)
File "e:\programdata\anaconda3\lib\signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
Just like the example code,but I couldn't run it successfully.
Thank you very much.
Instead of
form flask.ext.rq import RQ
should be
from flask.ext.rq import RQ
So I end up having to create an app context in order to do any jobs. I was wondering if it were possible to automatically include the app context.
I have to do this often
@job
def random():
with app.app_context():
x = 1 + 1
I would prefer to not have to type the
with app.app_context():
Hi thanks for the great lib.
Quick question is there currently a way to access the current_job? to acquire the job.id al la: http://python-rq.org/docs/jobs/
Thanks in advance
seems like task is not rename to job
Recently, I run the flask rq-worker with the flask-sqlalchemy in order to do some model operations by async-task in the worker. While it occasionally raised the Error
ResourceClosedError: This result object does not return rows. It has been closed automatically.
I don't know what happen to the worker cause the issue. I could not reproduce the error and have searched for a long time on the problem. While get nothing solution on it.
I wonder if any examples on flask-rq worked with flask-sqlalchemy? Here are the code snippets my own.
if __name__ == '__main__':
with app.app_context():
QUEUE = get_queue()
worker = get_worker()
worker.push_exc_handler(retry_handler)
worker.work()
And the async task
@job
def async_restart_task(task_id):
creating_info = {"status": TaskStatus.Creating} # NOTE: Reset created_at ?
task = TaskModel.update_task(task_id, creating_info)
task = TaskModel.get_task_by_id(task_id)
service = get_service(task.service)
for jobs in iter_group(10, service.gen_jobs(task)):
JobModel.add_jobs(jobs)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.