Files
hatchet/examples/python/streaming/async_stream.py
Matt Kaye 1cd12f24f8 Feat: Streaming Docs + Examples (#1912)
* feat: streaming examples + gen

* feat: more examples

* chore: gen again

* feat: fastapi example

* chore: gen

* feat: callout

* fix: typos

* fix: whoops - how did this work?

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-26 17:28:05 -04:00

18 lines
448 B
Python

import asyncio
from examples.streaming.worker import stream_task
from hatchet_sdk.clients.listeners.run_event_listener import StepRunEventType
async def main() -> None:
# > Consume
ref = await stream_task.aio_run_no_wait()
async for chunk in ref.stream():
if chunk.type == StepRunEventType.STEP_RUN_EVENT_TYPE_STREAM:
print(chunk.payload, flush=True, end="")
if __name__ == "__main__":
asyncio.run(main())