Skip to content

Instantly share code, notes, and snippets.

@cretz
Created August 16, 2022 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cretz/1474532ecbf12182fa5f6664e63df423 to your computer and use it in GitHub Desktop.
Save cretz/1474532ecbf12182fa5f6664e63df423 to your computer and use it in GitHub Desktop.
Simple Python Gists
@workflow.defn
class SayHello:
@workflow.run
async def run(self, name: str) -> str:
return f"Hello, {name}!"
@activity.defn
async def say_hello(name: str) -> str:
return f"Hello, {name}!"
@workflow.defn
class SayHello:
@workflow.run
async def run(self, name: str) -> str:
return await workflow.execute_activity(
say_hello, name, schedule_to_close_timeout=timedelta(seconds=5)
)
async def run_workflow():
client = await Client.connect("localhost:7233")
result = await client.execute_workflow(
SayHello.run,
"Temporal",
id="my-workflow-id",
task_queue="my-task-queue".
)
print(f"Result: {result}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment