Fix: Python docs examples (#2255)

* feat: client example

* fix: batch i

* fix: batch ii

* fix: batch iii

* fix: batch iv
This commit is contained in:
matt
2025-09-05 15:08:23 -04:00
committed by GitHub
parent 8c85f47cd8
commit 4a50e454a6
46 changed files with 404 additions and 275 deletions
@@ -0,0 +1,30 @@
# > Worker
import asyncio
from aiohttp import ClientSession
from hatchet_sdk import Context, EmptyModel, Hatchet
hatchet = Hatchet()
async def fetch(session: ClientSession, url: str) -> bool:
async with session.get(url) as response:
return response.status == 200
@hatchet.task(name="Fetch")
async def hello_from_hatchet(input: EmptyModel, ctx: Context) -> dict[str, int]:
num_requests = 10
async with ClientSession() as session:
tasks = [
fetch(session, "https://docs.hatchet.run/home") for _ in range(num_requests)
]
results = await asyncio.gather(*tasks)
return {"count": results.count(True)}
# !!