fix: await async def setup() coroutine instead of silently dropping it#2921
Merged
michaeldwan merged 1 commit intomainfrom Apr 9, 2026
Merged
fix: await async def setup() coroutine instead of silently dropping it#2921michaeldwan merged 1 commit intomainfrom
michaeldwan merged 1 commit intomainfrom
Conversation
Contributor
|
I'm Bonk, and I've done a quick review of your PR. This PR fixes a critical bug where The fix follows the same pattern used for
LGTM |
When a predictor has async def setup(), call_method0("setup") returns a
coroutine object. The ? operator only checks for Python exceptions, so
the coroutine was silently dropped -- setup appeared to succeed but none
of the setup code actually executed.
Detect whether setup() is async during load() (matching predict/train),
and run the coroutine with asyncio.run() when it is.
Fixes #2919
d0b3ac8 to
9018109
Compare
Contributor
|
LGTM |
markphelps
added a commit
that referenced
this pull request
Apr 13, 2026
…to test-harness-go * 'test-harness-go' of https://github.com/replicate/cog: fix: run async setup() on the same event loop as predict() (#2927) fix: support dict and list[dict] as predictor input types (#2928) fix: docs deploy workflow uses Go 1.23, can't parse go.mod tool directive (#2924) fix: await async def setup() coroutine instead of silently dropping it (#2921) chore(deps): bump actions/setup-go from 5 to 6 (#2767) fix: stub generation fails locally and produces unformatted output (#2920)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a predictor has
async def setup(), coglet calls it but doesn't await the coroutine. Setup appears to succeed -- logs say "Setup complete" and "Server ready" -- but none of the setup code actually executes. Every prediction then fails withAttributeErrorbecause attributes were never set.call_method0("setup")returns a coroutine object when setup is async. The?only checks for Python exceptions, so the coroutine was silently dropped.predict()andtrain()don't have this problem becauseload()callsdetect_async()for both andcall_method_raw()runs the coroutine withasyncio.run(). That pattern was never applied tosetup().The fix: detect whether
setup()is async duringload(), capture the return value insetup(), and run it withasyncio.run()when it's a coroutine.Three integration tests cover async setup with async predict, sync predict, and the weights parameter path.
Fixes #2919