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

async runner #1352

Merged
merged 4 commits into from
Nov 22, 2023
Merged

async runner #1352

merged 4 commits into from
Nov 22, 2023

Conversation

technillogue
Copy link
Contributor

@technillogue technillogue commented Oct 28, 2023

stacked PR on top of #1350 as well as #1355, this similarly only takes steps to eventually allow concurrent predictions. this PR starts with changing multiprocessing.pool.AsyncResult to asyncio.Task, and propagates the necessary async changes

  • have runner return asyncio.Task instead of AsyncFuture
  • making tests async

@nickstenning
Copy link
Member

I started rebasing this but without context it quickly turned into a bigger job than I hoped. Would you mind rebasing this on main so it's reviewable in its own right?

@technillogue
Copy link
Contributor Author

(did you mean something else about rebasing?)

@technillogue technillogue mentioned this pull request Oct 31, 2023
@nickstenning
Copy link
Member

(did you mean something else about rebasing?)

Yes! Your description here says:

stacked PR on top of #1350 as well as #1355,

Currently this PR is for a set of commits that we'd not want to merge to main without a rebase. Please rebase this branch on main so that it's a reviewable unit. Merging main achieves the same overall diff but it doesn't allow this PR to be reviewed commit by commit.

@technillogue technillogue force-pushed the syl/async-runner branch 5 times, most recently from 415d824 to 5b0b716 Compare November 6, 2023 17:52
@technillogue
Copy link
Contributor Author

had to brush up on how to rebase but once I remembered --onto I had it work without any conflicts. this is still stacked on #1355

@@ -450,6 +450,7 @@ def test_prediction_idempotent_endpoint_conflict(client, match):
json={"input": {"sleep": 1}},
headers={"Prefer": "respond-async"},
)
time.sleep(0.001)
Copy link
Member

Choose a reason for hiding this comment

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

Hmmmm. What's going on here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when I added it the test would fail because the second request would come in too quickly, but I think maybe the limiter change from async routes fixes it

return

result = app.state.setup_result.get()
result = await app.state.setup_result
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be clearer to do

Suggested change
result = await app.state.setup_result
result = app.state.setup_result.result()

here, because as written, this kind of implies that we might actually be waiting for it, which shouldn't happen.

Copy link
Member

Choose a reason for hiding this comment

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

Also do we need to handle cancellation of this task here?

Copy link
Contributor Author

@technillogue technillogue Nov 6, 2023

Choose a reason for hiding this comment

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

hm, yes, both result and await can raise CancelledError (or errors from setup). that code path would happen if we get a healthcheck while shutting down after being told to shut down... is that SETUP_FAILED? there's not a shutting-down state

unlike await, .result() can raise InvalidStateError but that should never be the case after checking .done()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's possible just propagating CancelledError and setup errors through to the healthcheck isn't the worst behavior, it should return 500 which seems reasonable

Copy link
Member

@nickstenning nickstenning left a comment

Choose a reason for hiding this comment

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

LGTM.

@technillogue
Copy link
Contributor Author

is this good to merge then?

don't make Worker._wait async for this PR because it's not strictly necessary and makes testing more confusing

Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
@technillogue technillogue enabled auto-merge (rebase) November 22, 2023 20:27
@technillogue technillogue merged commit b002d54 into main Nov 22, 2023
13 checks passed
@technillogue technillogue deleted the syl/async-runner branch November 22, 2023 20:36
technillogue added a commit that referenced this pull request Jan 16, 2024
Revert "review changes to tests and server"
Revert "delete remaining runner thread code :)"
Revert "make tests async and fix them"
Revert "have runner return asyncio.Task instead of AsyncFuture"

This reverts commit b002d54.
This reverts commit 087f482.
This reverts commit 6729d53.
This reverts commit dc5ef44.

Signed-off-by: technillogue <technillogue@gmail.com>
technillogue added a commit that referenced this pull request Jan 16, 2024
Revert "review changes to tests and server"
Revert "delete remaining runner thread code :)"
Revert "make tests async and fix them"
Revert "have runner return asyncio.Task instead of AsyncFuture"

This reverts commit b002d54.
This reverts commit 087f482.
This reverts commit 6729d53.
This reverts commit dc5ef44.

Signed-off-by: technillogue <technillogue@gmail.com>
technillogue added a commit that referenced this pull request Jan 16, 2024
Revert "review changes to tests and server"
Revert "delete remaining runner thread code :)"
Revert "make tests async and fix them"
Revert "have runner return asyncio.Task instead of AsyncFuture"

This reverts commit b002d54.
This reverts commit 087f482.
This reverts commit 6729d53.
This reverts commit dc5ef44.

Signed-off-by: technillogue <technillogue@gmail.com>
technillogue added a commit that referenced this pull request Jan 16, 2024
technillogue added a commit that referenced this pull request Jan 22, 2024
technillogue added a commit that referenced this pull request Feb 13, 2024
* have runner return asyncio.Task instead of AsyncFuture
* make tests async and fix them
* delete remaining runner thread code :)
* review changes to tests and server

(reverts commit 828eee9)
technillogue added a commit that referenced this pull request Feb 13, 2024
* have runner return asyncio.Task instead of AsyncFuture
* make tests async and fix them
* delete remaining runner thread code :)
* review changes to tests and server

(reverts commit 828eee9)
technillogue added a commit that referenced this pull request Feb 21, 2024
* have runner return asyncio.Task instead of AsyncFuture
* make tests async and fix them
* delete remaining runner thread code :)
* review changes to tests and server

(reverts commit 828eee9)

Signed-off-by: technillogue <technillogue@gmail.com>
technillogue added a commit that referenced this pull request Jun 19, 2024
* have runner return asyncio.Task instead of AsyncFuture
* make tests async and fix them
* delete remaining runner thread code :)
* review changes to tests and server

(reverts commit 828eee9)

Signed-off-by: technillogue <technillogue@gmail.com>
technillogue added a commit that referenced this pull request Jun 19, 2024
* have runner return asyncio.Task instead of AsyncFuture
* make tests async and fix them
* delete remaining runner thread code :)
* review changes to tests and server

(reverts commit 828eee9)

Signed-off-by: technillogue <technillogue@gmail.com>
technillogue added a commit that referenced this pull request Jul 18, 2024
* have runner return asyncio.Task instead of AsyncFuture
* make tests async and fix them
* delete remaining runner thread code :)
* review changes to tests and server

(reverts commit 828eee9)

Signed-off-by: technillogue <technillogue@gmail.com>
technillogue added a commit that referenced this pull request Jul 24, 2024
* have runner return asyncio.Task instead of AsyncFuture
* make tests async and fix them
* delete remaining runner thread code :)
* review changes to tests and server

(reverts commit 828eee9)

Signed-off-by: technillogue <technillogue@gmail.com>
@technillogue technillogue mentioned this pull request Jul 24, 2024
technillogue added a commit that referenced this pull request Jul 25, 2024
* have runner return asyncio.Task instead of AsyncFuture
* make tests async and fix them
* delete remaining runner thread code :)
* review changes to tests and server

(reverts commit 828eee9)

Signed-off-by: technillogue <technillogue@gmail.com>
technillogue added a commit that referenced this pull request Jul 25, 2024
* have runner return asyncio.Task instead of AsyncFuture
* make tests async and fix them
* delete remaining runner thread code :)
* review changes to tests and server

(reverts commit 828eee9)

Signed-off-by: technillogue <technillogue@gmail.com>
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.

2 participants