Skip to content

Commit 0b97542

Browse files
sdk-python: update v2 client, worker, and tests
1 parent 46038fd commit 0b97542

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/durable_workflow/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async def __aexit__(self, *exc: Any) -> None:
107107
await self.aclose()
108108

109109
def _headers(self, *, worker: bool = False) -> dict[str, str]:
110-
h: dict[str, str] = {"Content-Type": "application/json"}
110+
h: dict[str, str] = {"Content-Type": "application/json", "Accept": "application/json"}
111111
if self.token:
112112
h["Authorization"] = f"Bearer {self.token}"
113113
h["X-Namespace"] = self.namespace

src/durable_workflow/worker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(
3333
workflows: Iterable[type] = (),
3434
activities: Iterable[Callable[..., Any]] = (),
3535
worker_id: str | None = None,
36-
poll_timeout: float = 5.0,
36+
poll_timeout: float = 35.0,
3737
max_concurrent_workflow_tasks: int = 10,
3838
max_concurrent_activity_tasks: int = 10,
3939
shutdown_timeout: float = 30.0,
@@ -248,6 +248,7 @@ async def _poll_workflow_tasks(self) -> None:
248248
continue
249249
if task is None:
250250
self._wf_semaphore.release()
251+
await asyncio.sleep(0)
251252
continue
252253
self._track(self._dispatch_workflow_task(task))
253254

@@ -278,6 +279,7 @@ async def _poll_activity_tasks(self) -> None:
278279
continue
279280
if task is None:
280281
self._act_semaphore.release()
282+
await asyncio.sleep(0)
281283
continue
282284
self._track(self._dispatch_activity_task(task))
283285

tests/integration/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ def server_url() -> str:
2121

2222
@pytest.fixture(scope="session")
2323
def server_token() -> str:
24-
return os.environ.get("DURABLE_WORKFLOW_AUTH_TOKEN", "dev-token-123")
24+
return os.environ.get("DURABLE_WORKFLOW_AUTH_TOKEN", "test-token")

tests/test_worker.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ async def limited_activity() -> str:
348348
max_concurrent_activity_tasks=2,
349349
)
350350

351+
async def _acquire_and_dispatch(t: dict[str, object]) -> None:
352+
await worker._act_semaphore.acquire()
353+
await worker._dispatch_activity_task(t)
354+
351355
tasks = []
352356
for i in range(4):
353357
task = {
@@ -357,7 +361,7 @@ async def limited_activity() -> str:
357361
"arguments": "[]",
358362
"payload_codec": "json",
359363
}
360-
tasks.append(worker._track(worker._dispatch_activity_task(task)))
364+
tasks.append(worker._track(_acquire_and_dispatch(task)))
361365

362366
await asyncio.sleep(0.01)
363367
assert max_running == 2

0 commit comments

Comments
 (0)