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

Add Flask context automatically to APScheduler executors #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mxdev88
Copy link
Contributor

@mxdev88 mxdev88 commented Aug 14, 2021

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

@viniciuschiele
Copy link
Owner

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.

@mxdev88
Copy link
Contributor Author

mxdev88 commented Aug 14, 2021

Another option may be to act on the part that runs the job rather than on the job itself. Any thoughts on this?

@viniciuschiele
Copy link
Owner

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.

@mxdev88 mxdev88 changed the title Add Flask context automatically to added or modified jobs Add Flask context automatically to APScheduler executors Aug 22, 2021
@mxdev88
Copy link
Contributor Author

mxdev88 commented Aug 22, 2021

Hi @viniciuschiele - made another attempt, this time by decorating executors rather than the jobs. Let me know what you think. thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants