Skip to content

Commit 60f02ab

Browse files
andystaplesCopilot
andcommitted
Adapt replay regressions to cold async context
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 5e236c4 commit 60f02ab

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

‎tests/durabletask/test_asyncio_orchestrators.py‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ async def orchestrator(ctx: task.AsyncOrchestrationContext, _: Any) -> None:
500500
def test_call_at_deadline_is_exact_microsecond_ceiling(offset: float) -> None:
501501
requested: list[float] = []
502502

503-
async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> None:
503+
async def orchestrator(ctx: task.AsyncOrchestrationContext, _: Any) -> None:
504504
loop = asyncio.get_running_loop()
505505
when = loop.time() + offset
506506
requested.append(when)
@@ -523,7 +523,7 @@ async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> None:
523523

524524

525525
def test_call_at_known_float_deadline_rounds_up_to_next_microsecond() -> None:
526-
async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> None:
526+
async def orchestrator(ctx: task.AsyncOrchestrationContext, _: Any) -> None:
527527
loop = asyncio.get_running_loop()
528528
fired = loop.create_future()
529529
loop.call_at(loop.time() + 0.000003, fired.set_result, None)
@@ -535,7 +535,7 @@ async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> None:
535535

536536
@pytest.mark.parametrize("offset", [0.0, -1.0])
537537
def test_call_at_due_deadline_runs_without_durable_timer(offset: float) -> None:
538-
async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> str:
538+
async def orchestrator(ctx: task.AsyncOrchestrationContext, _: Any) -> str:
539539
loop = asyncio.get_running_loop()
540540
fired = loop.create_future()
541541
loop.call_at(loop.time() + offset, fired.set_result, "fired")
@@ -547,7 +547,7 @@ async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> str:
547547

548548
@pytest.mark.parametrize("when", [1e20, float(sys.float_info.max)])
549549
def test_call_at_out_of_range_deadline_fails(when: float) -> None:
550-
async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> None:
550+
async def orchestrator(ctx: task.AsyncOrchestrationContext, _: Any) -> None:
551551
asyncio.get_running_loop().call_at(when, lambda: None)
552552

553553
complete = _completion(_execute(orchestrator, [], _start()))
@@ -660,15 +660,15 @@ async def branch(index: int) -> None:
660660

661661

662662
async def _shared_future_cancellation_orchestrator(
663-
ctx: task.OrchestrationContext, _: Any, *, direct_future: bool, gather_wait: bool,
663+
ctx: task.AsyncOrchestrationContext, _: Any, *, direct_future: bool, gather_wait: bool,
664664
) -> str:
665665
loop = asyncio.get_running_loop()
666666
futures: list[asyncio.Future[None]] = [
667667
asyncio.Future[None]() if direct_future else loop.create_future() for _ in range(2)]
668668

669669
def on_cancelled(index: int, future: asyncio.Future[None]) -> None:
670670
assert future.cancelled()
671-
ctx.call_activity(f"cancelled-{index}")
671+
ctx.as_task_context().call_activity(f"cancelled-{index}")
672672

673673
for index, future in enumerate(futures):
674674
future.add_done_callback(partial(on_cancelled, index))
@@ -1083,7 +1083,7 @@ def test_cleanup_keeps_process_control_over_other_control_flow(
10831083
errors.reverse()
10841084
cleaned: list[int] = []
10851085

1086-
async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> None:
1086+
async def orchestrator(ctx: task.AsyncOrchestrationContext, _: Any) -> None:
10871087
async def branch(index: int) -> None:
10881088
try:
10891089
await ctx.wait_for_external_event(f"never-{index}")
@@ -1106,7 +1106,7 @@ def test_cleanup_closes_async_generators_started_during_generator_cleanup(
11061106
count: int, caplog: pytest.LogCaptureFixture) -> None:
11071107
closed: list[int] = []
11081108

1109-
async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> None:
1109+
async def orchestrator(ctx: task.AsyncOrchestrationContext, _: Any) -> None:
11101110
async def resource(index: int) -> AsyncIterator[int]:
11111111
try:
11121112
yield 1
@@ -1148,7 +1148,7 @@ def emit(self, record):
11481148
11491149
logging.getLogger().addHandler(Capture())
11501150
1151-
async def orchestrator(ctx: task.OrchestrationContext, _):
1151+
async def orchestrator(ctx: task.AsyncOrchestrationContext, _):
11521152
async def resource():
11531153
try:
11541154
yield 1
@@ -1191,7 +1191,7 @@ async def signal_on_forced_close():
11911191
def test_exhausted_async_generators_are_not_retained_until_dispatch_end() -> None:
11921192
references: list[ReferenceType[Any]] = []
11931193

1194-
async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> None:
1194+
async def orchestrator(ctx: task.AsyncOrchestrationContext, _: Any) -> None:
11951195
async def values() -> AsyncIterator[int]:
11961196
yield 1
11971197

@@ -1217,7 +1217,7 @@ def test_entity_lock_disposal_during_teardown_does_not_schedule_releases(
12171217
first = entities.EntityInstanceId("counter", "a")
12181218
second = entities.EntityInstanceId("counter", "b")
12191219

1220-
async def orchestrator(ctx: task.OrchestrationContext, _: Any) -> Any:
1220+
async def orchestrator(ctx: task.AsyncOrchestrationContext, _: Any) -> Any:
12211221
with await ctx.lock_entities([first, second]):
12221222
if suspend == "activity":
12231223
return await ctx.call_activity("inside-lock")

0 commit comments

Comments
 (0)