mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2025-12-31 13:49:48 -06:00
* api changes * doc changes * move docs * generated * generate * pkg * backmerge main * revert to main * revert main * race? * remove go tests
27 lines
521 B
Python
27 lines
521 B
Python
import asyncio
|
|
|
|
from hatchet_sdk import Context, EmptyModel, Hatchet
|
|
|
|
hatchet = Hatchet(debug=True)
|
|
|
|
# > Streaming
|
|
|
|
streaming_workflow = hatchet.workflow(name="StreamingWorkflow")
|
|
|
|
|
|
@streaming_workflow.task()
|
|
async def step1(input: EmptyModel, ctx: Context) -> None:
|
|
for i in range(10):
|
|
await asyncio.sleep(1)
|
|
ctx.put_stream(f"Processing {i}")
|
|
|
|
|
|
def main() -> None:
|
|
worker = hatchet.worker("test-worker", workflows=[streaming_workflow])
|
|
worker.start()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|