Skip to content

Commit e934306

Browse files
committed
Investigation: minimal repro
1 parent 634c5ec commit e934306

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ lint-types = [
8282
{ cmd = "uv run mypy --namespace-packages --check-untyped-defs ."},
8383
]
8484
run-bench = "uv run python scripts/run_bench.py"
85-
test = "uv run pytest"
85+
test = "uv run pytest tests/nexus/test_timeout.py"
8686

8787

8888
[tool.pytest.ini_options]

tests/nexus/test_timeout.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from __future__ import annotations
2+
3+
import asyncio
4+
import uuid
5+
from datetime import timedelta
6+
7+
import nexusrpc.handler
8+
import pytest
9+
10+
from temporalio import workflow
11+
from temporalio.testing import WorkflowEnvironment
12+
from tests.helpers import new_worker
13+
from tests.helpers.nexus import create_nexus_endpoint, make_nexus_endpoint_name
14+
15+
16+
@workflow.defn
17+
class NexusCallerWorkflow:
18+
"""Workflow that calls a Nexus operation."""
19+
20+
@workflow.run
21+
async def run(self) -> None:
22+
nexus_client = workflow.create_nexus_client(
23+
endpoint=make_nexus_endpoint_name(workflow.info().task_queue),
24+
service="MaxConcurrentTestService",
25+
)
26+
27+
await nexus_client.execute_operation(
28+
"op", None, schedule_to_close_timeout=timedelta(seconds=60)
29+
)
30+
31+
32+
async def test_max_concurrent_nexus_tasks(env: WorkflowEnvironment):
33+
if env.supports_time_skipping:
34+
pytest.skip("Nexus tests don't work with Javas test server")
35+
36+
@nexusrpc.handler.service_handler
37+
class MaxConcurrentTestService:
38+
@nexusrpc.handler.sync_operation
39+
async def op(
40+
self, _ctx: nexusrpc.handler.StartOperationContext, id: None
41+
) -> None:
42+
await asyncio.Event().wait()
43+
44+
async with new_worker(
45+
env.client,
46+
NexusCallerWorkflow,
47+
nexus_service_handlers=[MaxConcurrentTestService()],
48+
) as worker:
49+
await create_nexus_endpoint(worker.task_queue, env.client)
50+
51+
execute_workflow = env.client.execute_workflow(
52+
NexusCallerWorkflow.run,
53+
id=str(uuid.uuid4()),
54+
task_queue=worker.task_queue,
55+
)
56+
try:
57+
await asyncio.wait_for(execute_workflow, timeout=3)
58+
except TimeoutError:
59+
print("Saw expected timeout")
60+
pass
61+
else:
62+
pytest.fail("Expected timeout")

0 commit comments

Comments
 (0)