Created
August 16, 2022 20:39
-
-
Save cretz/1474532ecbf12182fa5f6664e63df423 to your computer and use it in GitHub Desktop.
Simple Python Gists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@workflow.defn | |
class SayHello: | |
@workflow.run | |
async def run(self, name: str) -> str: | |
return f"Hello, {name}!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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