Skip to content

Adds toggle schedule for python sample #3332

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import asyncio

from temporalio.client import (
Client,
ScheduleUpdateInput,
)

"""dacx
Create a function that toggles a schedule's paused state.
This function checks if the schedule is paused and either pauses or unpauses it accordingly.
"""

async def main():
client = await Client.connect("localhost:7233")
handle = client.get_schedule_handle(
"workflow-schedule-id",
)
schedule_description = await handle.describe()
is_paused = schedule_description.schedule.state.paused
if is_paused:
await handle.unpause(note="Unpausing the schedule")
else:
await handle.pause(note="Pausing the schedule")

if __name__ == "__main__":
asyncio.run(main())

""" @dacx
id: how-to-toggle-scheduled-workflow-execution-in-python
title: How to Toggle a Scheduled Workflow Execution in Python
label: Toggle a Scheduled Workflow Execution
description: Create a function that toggles a schedule's paused state.
This function checks if the schedule is paused and either pauses or unpauses it accordingly.
tags:
- scheduled workflow execution
- schedules
- python sdk
- code sample
lines: 10-14, 23-28
@dacx """