-
-
Notifications
You must be signed in to change notification settings - Fork 719
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
Move async user tasks to thread #7339
base: main
Are you sure you want to change the base?
Conversation
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 20 files ±0 20 suites ±0 11h 28m 28s ⏱️ - 30m 24s For more details on these failures, see this check. Results for commit 2241969. ± Comparison against base commit 9255987. ♻️ This comment has been updated with latest results. |
distributed/worker.py
Outdated
@@ -2247,13 +2247,12 @@ async def execute(self, key: str, *, stimulus_id: str) -> StateMachineEvent: | |||
try: | |||
ts.start_time = time() | |||
if iscoroutinefunction(function): | |||
result = await apply_function_async( |
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.
Could now also remove the definition of (the now unused) apply_function_async
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.
LGTM. Thanks, @fjetter!
+1 on this approach, I'd love to not let user code run in our event loop. This also would have made #5997 a bit easier, since we'd lose the ability to cancel user async tasks (so we wouldn't have to special-case rescheduling them). |
FYI this is currently soft blocked. Prefect is using this feature quite heavily and they observed some change in behavior relating to exception handling. |
@fjetter — just to confirm, this means that user-submitted async tasks are now running on multiple threads and event loops instead of a single thread and event loop? |
Yes, exactly. |
This should be good to go from our end! Thanks for letting us investigate. |
5d10974
to
f1028a1
Compare
f1028a1
to
2241969
Compare
This came up in #7320 in context of cancellation of these tasks during worker closing