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

Missing on_success and on_failure args in jobfunction.queue() #116

Open
richardfat7 opened this issue Aug 14, 2021 · 5 comments
Open

Missing on_success and on_failure args in jobfunction.queue() #116

richardfat7 opened this issue Aug 14, 2021 · 5 comments

Comments

@richardfat7
Copy link

richardfat7 commented Aug 14, 2021

in this line and this line, the enqueue_call didn't recognise on_success and on_failure args, and passed it as kargs if supplied in function call.
RQ related source

Sample code:

from flask_rq2 import RQ
from flask import Flask

app = Flask(__name__)
rq = RQ()

rq.init_app(app)

@rq.job()
def do_something():
    return "OK"

def report_success(*args, **kargs):
    print("success")

def report_failure(*args, **kargs):
    print("fail")

def try_to_queue():
    do_something.queue(queue="default", on_success = report_success, on_failure = report_failure)

try_to_queue()
@MaxVRAM
Copy link

MaxVRAM commented Aug 19, 2021

I've been stuck on working out how to make a success callback in RQ2. But it seems like it's not implemented, so will probably go back to vanilla RQ.

@mzpqnxow
Copy link

mzpqnxow commented Oct 30, 2021

I haven't looked at the source yet but it seems it should be a relatively simple addition. Any comment on whether this is supported in some other way, or if there are plans to implement it?

EDIT: @MaxVRAM, @richardfat7 , I added this and submitted as PR #118. There are instructions on how to install directly from that branch if you'd like to give it a shot. It works on my application. I'll need the Flask-RQ2 devs to review and merge if you'd like this to be available in the PyPi package

@mzpqnxow
Copy link

If this can be reviewed and consider for merge, that'd be terrific. Until then I'll maintain a separate branch

Thanks Flask-RQ2 devs for the work on this project- it makes things look so much cleaner

@richardfat7
Copy link
Author

Thanks @mzpqnxow . But I have fail back to use rq directly in flask.

@chunchunmaru0
Copy link

what I did was import rq from current instance and get the queue then enqueue the job

from .tasks import rq

        q = rq.get_queue()
        job = q.enqueue(calculate, args=(1, 2), kwargs={}, on_success=log_every_second)

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

4 participants