-
Notifications
You must be signed in to change notification settings - Fork 108
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
Make sure event loop is running before running coroutines in executor #9664
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9664 +/- ##
===========================================
+ Coverage 80.54% 91.73% +11.19%
===========================================
Files 428 430 +2
Lines 26619 26668 +49
===========================================
+ Hits 21439 24463 +3024
+ Misses 5180 2205 -2975
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #9664 will not alter performanceComparing Summary
|
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.
This seems to put the application in a bad state in case the condition is ever false.
I was unable to reproduce this with asyncio, but it was possible when using lower level ThreadPoolExecutor. https://superfastpython.com/threadpoolexecutor-shutdown/ |
src/ert/run_models/base_run_model.py
Outdated
event, | ||
iteration, | ||
) | ||
if asyncio.get_running_loop().is_running(): |
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.
Hm, this I think is redundant as this should be always true as this runs inside asyncio.run(...)
I would recommend instead:
loop = asyncio.get_running_loop()
if loop.is_closed():
self.send_snapshot_event(event, iteration)
else:
await asyncio.get_running_loop().run_in_executor(
None,
self.send_snapshot_event,
event,
iteration,
)
Maybe it helps if this evaluator function will become async:
Currently we call it directly from async context. |
So I think we need to reproduce before anything else, as it is, I am not sure whether this is worse or better. |
Issue
Resolves #9307
Approach
Make sure event loop is running before running coroutines in executor
(Screenshot of new behavior in GUI if applicable)
git rebase -i main --exec 'pytest tests/ert/unit_tests -n logical -m "not integration_test"'
)When applicable