-
Notifications
You must be signed in to change notification settings - Fork 557
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
async runner #1352
Conversation
ff833c7
to
ba06ec2
Compare
I started rebasing this but without context it quickly turned into a bigger job than I hoped. Would you mind rebasing this on |
(did you mean something else about rebasing?) |
Yes! Your description here says: 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 |
415d824
to
5b0b716
Compare
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 |
5b0b716
to
a1f92b3
Compare
python/tests/server/test_http.py
Outdated
@@ -450,6 +450,7 @@ def test_prediction_idempotent_endpoint_conflict(client, match): | |||
json={"input": {"sleep": 1}}, | |||
headers={"Prefer": "respond-async"}, | |||
) | |||
time.sleep(0.001) |
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.
Hmmmm. What's going on here?
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.
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
python/cog/server/http.py
Outdated
return | ||
|
||
result = app.state.setup_result.get() | ||
result = await app.state.setup_result |
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.
I think it might be clearer to do
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.
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.
Also do we need to handle cancellation of this task here?
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, 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()
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.
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
b0e7bd6
to
495f4db
Compare
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.
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>
495f4db
to
048d38f
Compare
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>
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>
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>
This reverts commit 828eee9.
This reverts commit 828eee9.
* 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)
* 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)
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
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