mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-25 01:58:42 -06:00
* feat: initial pass at first parts of blog post * feat: initial mkdocs setup * feat: first pass at embedding mkdocs * fix: config * debug: paths * fix: unwind docs hack * feat: start working on mkdocs theme * fix: paths * feat: wrap up post * fix: proof * fix: doc links * fix: rm docs * fix: lint * fix: lint * fix: typos + tweak * fix: tweaks * fix: typo * fix: cleanup
38 lines
922 B
Python
38 lines
922 B
Python
# ruff: noqa: E402
|
|
|
|
import asyncio
|
|
|
|
# ❓ Running a Task
|
|
from examples.child.worker import SimpleInput, child_task
|
|
|
|
child_task.run(SimpleInput(message="Hello, World!"))
|
|
# !!
|
|
|
|
# ❓ Schedule a Task
|
|
from datetime import datetime, timedelta
|
|
|
|
child_task.schedule(
|
|
datetime.now() + timedelta(minutes=5), 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"])
|
|
# !!
|