Files
hatchet/sdks/python/examples/timeout/test_timeout.py
Matt Kaye 46edb1f0b0 [Python] Fix: Remove global event loop setters everywhere (#1452)
* feat: factor out async to sync

* feat: remove global event loop setter in workflow listener

* fix: rm more global loop sets

* fix: more loop sets

* fix: more

* fix: more

* fix: rm one more

* fix: stream from thread

* fix: dispatcher

* fix: make tests have independent loop scopes (woohoo!)

* feat: use default loop scope

* fix: try adding back tests

* Revert "fix: try adding back tests"

This reverts commit bed34a9bae539650e4fe32e0518aa9d1c5c0af5c.

* fix: rm dead code

* fix: remove redundant `_utils`

* fix: add typing to client stubs + regenerate

* fix: create more clients lazily

* fix: print cruft

* chore: version

* fix: lint
2025-03-31 13:58:50 -04:00

21 lines
593 B
Python

import pytest
from examples.timeout.worker import refresh_timeout_wf, timeout_wf
from hatchet_sdk import Hatchet
# requires scope module or higher for shared event loop
@pytest.mark.asyncio()
async def test_execution_timeout(hatchet: Hatchet) -> None:
run = timeout_wf.run_no_wait()
with pytest.raises(Exception, match="(Task exceeded timeout|TIMED_OUT)"):
await run.aio_result()
@pytest.mark.asyncio()
async def test_run_refresh_timeout(hatchet: Hatchet) -> None:
result = await refresh_timeout_wf.aio_run()
assert result["refresh_task"]["status"] == "success"