Skip to content

[Feature Request] Improve wait_condition semantics #618

@dandavison

Description

@dandavison

Ideally, the following would not happen:

@workflow.defn
class WaitForSharedMutableStateWorkflow:
    def __init__(self) -> None:
        self.cond = False

    @workflow.run
    async def run(self):
        self.cond = True
        await asyncio.gather(self.coro("1"), self.coro("2"))

    async def coro(self, id: str):
        await workflow.wait_condition(lambda: self.cond)
        print(f"after wait coro {id} sees {self.cond}")  # ❗❗ <== coro2 sees False❗
        self.cond = False
        await asyncio.sleep(1)
        self.cond = True

Completely eliminating the possibility would be ideal, but best-effort improvements would also be welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions