Files
hatchet/sdks/python/examples/child/trigger.py
Gabe Ruttner 339f505612 Docs: run and wait, child run in run and wait, run no wait, bulk (#1472)
* run and wait

* run no wait

* bulk

* release: 1.1.1

* lint

* lint?

* lint

* lint?

* discord link

* separate examples

* lint

* prettier

* move new examples

* lint

* python...

* fix: python examples

* rm toolchain

---------

Co-authored-by: mrkaye97 <mrkaye97@gmail.com>
2025-04-02 12:20:19 -07:00

28 lines
729 B
Python

import asyncio
# ❓ Running a Task
from examples.child.worker import SimpleInput, child_task
child_task.run(SimpleInput(message="Hello, World!"))
# !!
async def main() -> None:
# ❓ Running a Task AIO
result = await child_task.aio_run(SimpleInput(message="Hello, World!"))
# !!
print(result)
# ❓ Running Multiple Tasks
result1 = child_task.aio_run(SimpleInput(message="Hello, World!"))
result2 = child_task.aio_run(SimpleInput(message="Hello, Moon!"))
# gather the results of the two tasks
results = await asyncio.gather(result1, result2)
# print the results of the two tasks
print(results[0]["transformed_message"])
print(results[1]["transformed_message"])
# !!