mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2025-12-31 21:59:49 -06:00
* fix: stop trying to parse payloads back from json
* feat: streaming example
* feat: aio output
* fix: lint
* feat: sync and async examples
* fix: small issues
* fix: one more small thing
* chore: version
* fix: lint
* fix: add sleeps
* feat: factor out run_async_from_sync
* Revert "feat: factor out run_async_from_sync"
This reverts commit fb37395913.
* fix: schedule trigger namespace issue
* fix: log error if action payload fails to decode but don't raise out of listener
28 lines
532 B
Python
28 lines
532 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()
|