-
Notifications
You must be signed in to change notification settings - Fork 7
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 #1109
Flask-Apscheduler #1109
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #1109 +/- ##
==========================================
+ Coverage 85.74% 86.03% +0.29%
==========================================
Files 28 29 +1
Lines 3241 3237 -4
==========================================
+ Hits 2779 2785 +6
+ Misses 462 452 -10
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't get it working in Gunicorn (which is used for production). I have a task that triggers correctly when running via flask
(standard docker-compose), but it does not trigger when I run in Gunicorn. If we can't get it working in Gunicorn, I do not see a reason to use it at all.
a naive question, but are you sure that it just doesn't seem that way after Ina's latest commit, which commented out all print/debug statements? |
Gives me the following when I start with
While I only get an empty file if I start with Gunicorn. I tested using the action log after failing to get any output in gunicorn with normal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With our current Gunicorn setup, there will be two schedulers running in parallell, meaning that each task is run twice each timestep. Using my earlier example:
{"who": {"user": "print_test", "role": "2022-03-30 10:49:47.573795"}, "by_whom": {"user": "print_test", "role": "scheduler"}, "event": "apscheduler print_test", "logger": "actions", "level": "info", "timestamp": "2022-03-30T10:49:47.573850Z"}
{"who": {"user": "print_test", "role": "2022-03-30 10:49:47.575475"}, "by_whom": {"user": "print_test", "role": "scheduler"}, "event": "apscheduler print_test", "logger": "actions", "level": "info", "timestamp": "2022-03-30T10:49:47.575616Z"}
{"who": {"user": "print_test", "role": "2022-03-30 10:49:49.577357"}, "by_whom": {"user": "print_test", "role": "scheduler"}, "event": "apscheduler print_test", "logger": "actions", "level": "info", "timestamp": "2022-03-30T10:49:49.577386Z"}
{"who": {"user": "print_test", "role": "2022-03-30 10:49:49.580273"}, "by_whom": {"user": "print_test", "role": "scheduler"}, "event": "apscheduler print_test", "logger": "actions", "level": "info", "timestamp": "2022-03-30T10:49:49.580313Z"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my suggestion. We need to discuss what to do with the gunicorn setup later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the changes after 1.12.1 fixes the bug we see in our tests. But that fix seems to instead cause the issues in Gunicorn. Yay.
Co-authored-by: Linus Östberg <linus.ostberg@scilifelab.uu.se>
Co-authored-by: Linus Östberg <linus.ostberg@scilifelab.uu.se>
cf339e4
to
8a23aca
Compare
Same as #1108 but without the mess.
Change the scheduled tasks to use Flask-Apscheduler instead -- this means that the setup structure is like the migrations, database etc etc. (
init_app(app)
)Have also removed the scheduler stuff from the
utils.py
module, and now the scheduled tasks are in a new file, and set up with the help of decorators.There may be some more config needed but we'll notice that as we add the tasks. Also, the first task here is just an example and something that @valyo has started on implementing, but since there are more than one that's working on cronjobs etc now, I want to merge this before anyone starts so that it all works.
The previous solution currently has issues with the app context.
dev
branch