Repository navigation
Conversation
An `async def` body runs only when it is awaited, so a call that is never awaited is lost. The guard runs when code takes the method, before any coroutine exists.
The sample's support guard records each call and refuses one from a plain function of a caller. Its tests show that a call with no await fails at its line.
Authors need the call that the class makes and why a check inside the method can't catch a lost call. Co-authored-by: Tim Conley <timothy.conley@temporal.io>
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.
What changed?
This PR adds
@nexus.guard, which makes a resource class call a support function each time code takes one of its methods./// @nexus.guard python="check_stream_call" resource %stream { constructor(ref: stream-ref, created: option<bool>); }async def. The check sits in a__getattribute__that a type checker doesn't see, so a misspelled method is still an error.Stream.Why?
A Workflow
Streamworks only in Workflow code, and a clientStreamonly outside it. A plain function, such as the predicate of atake, can't await. Itsstream.append(x)makes a coroutine that never runs, so the write is lost with no error. A check inside theasync defcan't catch that, because its body never runs.How did you test it?
cargo validatepasses. The stream tests check that a call with noawaitraises at its line, and thatinspect.iscoroutinefunctionis still true for a guarded method. Unit tests cover the parser, the catalog and the set of guarded names.Link to a test plan if any -