Open cpg1111 opened 1 month ago
await child.result()
This is not valid API and a type checker should catch this. Starting a child workflow returns a ChildWorkflowHandle
which is an asyncio.Task
that is already waiting on result and should be awaited itself to get the result (e.g. just await child
). This is unlike starting a workflow from a client which uses a workflow handle that can be fetched in other ways and therefore is not always a task and therefore does have a separate .result()
to start the awaiting process.
Ah ok, yes that fixed it. I didn't see anything around this in the docs regarding ChildWorkflowHandle
, just that it inherits from asycnio.Task
, I'd be happy to submit a PR including this, assuming the docs are autogenerated?
Unsure which docs you are referring to (there is https://github.com/temporalio/sdk-python/blob/main/README.md, https://python.temporal.io, and https://docs.temporal.io/develop/python/) but yes, we happily accept contributions on them all.
I was referring to the second link, but I can submit PRs to the others where it makes sense.
API docs make sense. That is auto generated from docstrings yes. PRs to this repo welcome to update those API docs.
What are you really trying to do?
Hi there, I am writing tests for a workflow in which it spawns N child workflows using
workflow.start_child_workflow()
, places them in a list, and resolves the result later, like the following example:and test code like the following:
Describe the bug
Even when I have that exact child workflow, I get an
InvalidStateError
sayingResult is not set
. If I do not put the handler in a list and immediately callawait child.result()
it blocks indefinitely. However if I useworkflow.execute_child_workflow()
everything works fine. It's also worth noting these workflows work fine in an actual execution, this issue only exists using thetesting.WorkflowEnvironment
.Minimal Reproduction
Write a workflow that calls multiple child workflows using
workflow.start_child_workflow()
, write a test with a single sleep before awaiting the parent's result.Environment/Versions
Additional context
N/A