flask-apscheduler
flask-apscheduler copied to clipboard
Add Flask context automatically to APScheduler executors
This PR adds the Flask context to added or modified jobs automaticall. Most of the time when using Flask-APScheduler, you need to access something from your Flask app which requires to add the context yourself.
This should solve issues like mentioned here #176
I guess this code only works when the jobs are kept in memory, if you use a storage like sqlite/sqlalchemy it won't work.
Another option may be to act on the part that runs the job rather than on the job itself. Any thoughts on this?
It is APScheduler
that runs the jobs and it doesn't allow me to add some sort of "middleware" to initialize a Flask context before calling the actual method. If you find a workaround for that, I will be happy to merge it.
Hi @viniciuschiele - made another attempt, this time by decorating executors rather than the jobs. Let me know what you think. thanks!