GithubHelp home page GithubHelp logo

flask-rq's People

Contributors

jeanphix avatar mattupstate avatar stringertheory avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flask-rq's Issues

One connection per request?

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.

Is this project still alive?

@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.

AttributeError: 'RQ' object has no attribute 'job'

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'

Can't let worker to handle with the job in queue

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.

Example README typo

Instead of

form flask.ext.rq import RQ

should be

from flask.ext.rq import RQ

Being able to submit jobs without pushing the context around

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():

Using flask-rq with flask-sqlalchemy occasionally raise ResourceClosedError

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.