Skip to content

Introduce attempt completion event #83

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

Merged
merged 2 commits into from
Apr 24, 2025

Conversation

igalshilman
Copy link
Contributor

@igalshilman igalshilman commented Apr 24, 2025

greeter = Service("greeter")

@greeter.handler()
async def greet(ctx: Context, name: str) -> str:

    e = ctx.request().attempt_finished_event

    async def long_running_task():
        while True:
            if e.is_set():
                print("teardown event set", flush=True)
                return "this does not matter anymore"
            await asyncio.sleep(1)

    await ctx.run("hi", long_running_task, args=())
    return f"Hello {name}!"

@igalshilman igalshilman force-pushed the add_abort_controller branch from ed57d59 to ea3772d Compare April 24, 2025 16:25
@igalshilman igalshilman merged commit 7bcd910 into restatedev:main Apr 24, 2025
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant