-
Notifications
You must be signed in to change notification settings - Fork 185
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
Flask-APScheduler not running when set some environment variables #220
Comments
@GodsDusk Can you share an example? |
here is an example:
# run.py
from flask import Flask
from flask_apscheduler import APScheduler
scheduler = APScheduler()
@scheduler.task("interval", id="job1", seconds=3, misfire_grace_time=900)
def job1():
"""Sample job 1."""
print("Job 1 executed")
if __name__ == "__main__":
app = Flask(__name__)
scheduler.init_app(app)
scheduler.start()
from gevent.pywsgi import WSGIServer
http_server = WSGIServer(('0.0.0.0', 5001), app)
http_server.serve_forever() first, I exec Then, I exec |
Well, in development you can use the flask dev server, using one of these excellent examples: https://github.com/viniciuschiele/flask-apscheduler/tree/master/examples Using a production server + debug will prevent the scheduler from starting
This was done to allow development to work with the flask debugger. You could tweak your startup to look something like: from flask.helpers import get_debug_flag
if get_debug_flag():
app.run()
else:
.... wsgi server run forever |
set FLASK_ENV=development or FLASK_DEBUG any value
The text was updated successfully, but these errors were encountered: