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

scheduler.resume_job failed to work #214

Open
hongbo-miao opened this issue Dec 2, 2022 · 0 comments
Open

scheduler.resume_job failed to work #214

hongbo-miao opened this issue Dec 2, 2022 · 0 comments

Comments

@hongbo-miao
Copy link

hongbo-miao commented Dec 2, 2022

I have an interval job which prints number every 1 second.
In the beginning the job is paused by default.

However, in the code scheduler.resume() works, but scheduler.resume_job(my_task_id) does not work.
Here is the minimum reproduce repo: https://github.com/Hongbo-Miao/bug-flask-apscheduler

from flask import Flask
from flask_apscheduler import APScheduler

my_num = 0


def create_app() -> Flask:
    app = Flask(__name__)
    scheduler = APScheduler()
    scheduler.init_app(app)
    scheduler.start(paused=True)

    @scheduler.task(
        "interval",
        id="my_task_id",
        seconds=1,
    )
    def increase_my_num():
        global my_num
        print(f"my_num: {my_num}")
        my_num += 1

    @app.route("/")
    def my_num():
        global my_num

        # 1) This works
        # scheduler.resume()

        # 2) This doesn't work
        scheduler.resume_job("my_task_id")

        return {"my_num": my_num}

    return app

Please let me know if need anything else. Thanks! 😃

@hongbo-miao hongbo-miao changed the title scheduler.resume_job does not work scheduler.resume_job failed to work Dec 2, 2022
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

1 participant