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

Move async user tasks to thread #7339

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fjetter
Copy link
Member

@fjetter fjetter commented Nov 21, 2022

This came up in #7320 in context of cancellation of these tasks during worker closing

@github-actions
Copy link
Contributor

github-actions bot commented Nov 21, 2022

Unit Test Results

See 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
  3 754 tests ±0    3 641 ✔️  -   2     106 💤 ±0    7 +  2 
36 314 runs  ±0  34 532 ✔️  - 29  1 748 💤 ±0  34 +29 

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.

@@ -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(
Copy link
Contributor

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

Copy link
Member

@hendrikmakait hendrikmakait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks, @fjetter!

@gjoseph92
Copy link
Collaborator

+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).

@fjetter
Copy link
Member Author

fjetter commented Dec 1, 2022

FYI this is currently soft blocked. Prefect is using this feature quite heavily and they observed some change in behavior relating to exception handling.
Since they are a big user of this feature and we're not in a rush, we'll wait a bit for them to look into it

@zanieb
Copy link
Contributor

zanieb commented Dec 6, 2022

@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?

@fjetter
Copy link
Member Author

fjetter commented Dec 8, 2022

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.

@zanieb
Copy link
Contributor

zanieb commented Jan 3, 2023

This should be good to go from our end! Thanks for letting us investigate.

@fjetter fjetter force-pushed the move_async_to_thread branch from f1028a1 to 2241969 Compare August 7, 2023 15:06
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.

5 participants