@@ -521,21 +521,24 @@ async def test_child_runs_includes_run_started_in_this_attempt(
521521 [
522522 pytest .param ('start' , id = 'start' ),
523523 pytest .param ('call' , id = 'call' ),
524+ pytest .param ('call_task' , id = 'call task' ),
524525 ],
525526)
526- async def test_abort_with_parent_requires_name (
527+ async def test_abort_with_parent_requires_run_name (
527528 apify_client_async_patcher : ApifyClientAsyncPatcher , method : str
528529) -> None :
529- """`abort_with_parent` without a `name` raises before any run is started."""
530- apify_client_async_patcher .patch ('actor' , 'start' , return_value = make_run ('new-run' , 'READY' ))
531- apify_client_async_patcher .patch ('actor' , 'call' , return_value = make_run ('new-run' , 'SUCCEEDED' ))
530+ """`abort_with_parent` without a `run_name` raises before any run is started."""
531+ for resource in ('actor' , 'task' ):
532+ apify_client_async_patcher .patch (resource , 'start' , return_value = make_run ('new-run' , 'READY' ))
533+ apify_client_async_patcher .patch (resource , 'call' , return_value = make_run ('new-run' , 'SUCCEEDED' ))
532534
533535 async with Actor :
534536 with pytest .raises (ValueError , match = 'requires `run_name`' ):
535- await getattr (Actor , method )('some-actor ' , abort_with_parent = True )
537+ await getattr (Actor , method )('some-id ' , abort_with_parent = True )
536538
537- assert apify_client_async_patcher .calls ['actor' ]['start' ] == []
538- assert apify_client_async_patcher .calls ['actor' ]['call' ] == []
539+ for resource in ('actor' , 'task' ):
540+ assert apify_client_async_patcher .calls [resource ]['start' ] == []
541+ assert apify_client_async_patcher .calls [resource ]['call' ] == []
539542
540543
541544async def test_named_start_records_abort_with_parent (apify_client_async_patcher : ApifyClientAsyncPatcher ) -> None :
@@ -550,6 +553,21 @@ async def test_named_start_records_abort_with_parent(apify_client_async_patcher:
550553 assert stored ['scrape-eu' ]['abortWithParent' ] is True
551554
552555
556+ async def test_named_call_task_records_abort_with_parent (
557+ apify_client_async_patcher : ApifyClientAsyncPatcher ,
558+ ) -> None :
559+ """A named task call with `abort_with_parent` records the flag with the run."""
560+ apify_client_async_patcher .patch ('task' , 'start' , return_value = make_run ('new-run' , 'READY' ))
561+ apify_client_async_patcher .patch ('run' , 'wait_for_finish' , return_value = make_run ('new-run' , 'SUCCEEDED' ))
562+
563+ async with Actor :
564+ await Actor .call_task ('some-task' , run_name = 'scrape-eu' , abort_with_parent = True )
565+ kvs = await Actor .open_key_value_store ()
566+ stored = await kvs .get_value (CHILD_RUNS_KEY )
567+
568+ assert stored ['scrape-eu' ]['abortWithParent' ] is True
569+
570+
553571async def test_reattach_replaces_recorded_abort_with_parent (
554572 apify_client_async_patcher : ApifyClientAsyncPatcher ,
555573) -> None :
@@ -734,7 +752,7 @@ async def test_exit_removes_the_aborting_listener(
734752
735753 async with apify_event_manager :
736754 async with Actor :
737- await Actor .start ('some-actor' , name = 'scrape-eu' , abort_with_parent = True )
755+ await Actor .start ('some-actor' , run_name = 'scrape-eu' , abort_with_parent = True )
738756 apify_event_manager .emit (event = Event .ABORTING , event_data = EventAbortingData ())
739757 await apify_event_manager .wait_for_all_listeners_to_complete ()
740758
@@ -750,7 +768,7 @@ async def test_removing_all_aborting_listeners_keeps_aborting_child_runs(
750768 apify_client_async_patcher .patch ('run' , 'abort' , return_value = None )
751769
752770 async with Actor :
753- await Actor .start ('some-actor' , name = 'scrape-eu' , abort_with_parent = True )
771+ await Actor .start ('some-actor' , run_name = 'scrape-eu' , abort_with_parent = True )
754772 apify_event_manager .off (event = Event .ABORTING )
755773 apify_event_manager .emit (event = Event .ABORTING , event_data = EventAbortingData ())
756774 await apify_event_manager .wait_for_all_listeners_to_complete ()
0 commit comments