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

Break TaskRunEngine into Sync and Async classes #14643

Closed
wants to merge 4 commits into from

Conversation

bunchesofdonald
Copy link
Contributor

This PR is meant to address the issue where the TaskRunEngine is blocking async tasks. The PR fixes this issue by doing a major refactor of TaskRunEngine into three parts:

  • BaseTaskRunEngine - The core parts that are all sync and non-blocking.
  • SyncTaskRunEngine - The bits that are sync and blocking, mostly dealing with the client.
  • AsyncTaskRunEngine - The bits that are async, again mostly dealing with the client.

A lot of the refactor was also to break apart longer methods, like setup_run_context or begin_run into component parts that can be used by both the sync and async implementations.

Closes #14113

@bunchesofdonald bunchesofdonald added the enhancement An improvement of an existing feature label Jul 16, 2024
@bunchesofdonald bunchesofdonald requested a review from a team as a code owner July 16, 2024 20:37
Copy link

codspeed-hq bot commented Jul 16, 2024

CodSpeed Performance Report

Merging #14643 will not alter performance

Comparing issue-14113 (10621f8) with main (21dd874)

Summary

✅ 5 untouched benchmarks

Copy link
Collaborator

@chrisguidry chrisguidry left a comment

Choose a reason for hiding this comment

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

I was expecting to see more new tests, how well are we covering the async engine right now? I'm assuming we have a ton of tests for async tasks already and we're leaning on those? If so, that's super cool

src/prefect/task_engine.py Show resolved Hide resolved
@bunchesofdonald
Copy link
Contributor Author

I was expecting to see more new tests, how well are we covering the async engine right now? I'm assuming we have a ton of tests for async tasks already and we're leaning on those? If so, that's super cool

Yeah, we cover them both pretty equally because we have two different entrypoints depending on sync/async. I considered trying to have literal test parity, but it didn't seem to make much sense given the current layout of the suite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Task run creation blocks the event loop
2 participants