Reputation: 31
I use
from gevent import monkey
monkey.patch_all()
and use apscheduler.BackgroundScheduler()
use gunicorn run flask:
gunicorn -w 4 -b 0.0.0.0:9999 -k gevent main:app --preload
the cronjob start in main.py, it start once, but run 4 times. if I not use monkey.patch_all(), it run once. Why and how can I use monkey patch and run cronjob once.
I use sse(server-send-event), so I have to use gevent and the monkey patch.
Upvotes: 0
Views: 509
Reputation: 21
You should try to up (or install) watchdog on your environement.
Personally i don't use monkey, you can try from gevent :
from gevent.pywsgi import WSGIServer
if __name__ == "__main__":
http_server = WSGIServer(("0.0.0.0", 5001), app).serve_forever()
Upvotes: 0