Skip to content Skip to sidebar Skip to footer

Apscheduler Running Jobs Concurrently In Flask

In Flask I'm attempting to run several jobs concurrently. But I'm faced with this issue: This typically means that you attempted to use functionality that needed to interface with

Solution 1:

Your "chron" function is calling Flask current_app and jsonify() but it seems you haven't pushed a Flask context yet thus having this outside app context runtime error.

Before you can call a "contexted" func, you need to push your Flask app context.

Two ways of doing so,

app = Flask(__name__)
# do some stuff on your app if you need
app.app_context().push()
# do some other stuff

or in your chron func,

with app.app_context():
    # do something

You can refer to manually pushing a context for more details

Post a Comment for "Apscheduler Running Jobs Concurrently In Flask"