33from hyperbrowser .models .consts import POLLING_ATTEMPTS
44from ...polling import (
55 build_fetch_operation_name ,
6+ build_operation_name ,
67 collect_paginated_results_async ,
78 poll_until_terminal_status_async ,
89 retry_operation_async ,
@@ -63,9 +64,10 @@ async def start_and_wait(
6364 job_id = job_start_resp .job_id
6465 if not job_id :
6566 raise HyperbrowserError ("Failed to start batch scrape job" )
67+ operation_name = build_operation_name ("batch scrape job " , job_id )
6668
6769 job_status = await poll_until_terminal_status_async (
68- operation_name = f"batch scrape job { job_id } " ,
70+ operation_name = operation_name ,
6971 get_status = lambda : self .get_status (job_id ).status ,
7072 is_terminal_status = lambda status : status in {"completed" , "failed" },
7173 poll_interval_seconds = poll_interval_seconds ,
@@ -75,7 +77,7 @@ async def start_and_wait(
7577
7678 if not return_all_pages :
7779 return await retry_operation_async (
78- operation_name = build_fetch_operation_name (f"batch scrape job { job_id } " ),
80+ operation_name = build_fetch_operation_name (operation_name ),
7981 operation = lambda : self .get (job_id ),
8082 max_attempts = POLLING_ATTEMPTS ,
8183 retry_delay_seconds = 0.5 ,
@@ -101,7 +103,7 @@ def merge_page_response(page_response: BatchScrapeJobResponse) -> None:
101103 job_response .error = page_response .error
102104
103105 await collect_paginated_results_async (
104- operation_name = f"batch scrape job { job_id } " ,
106+ operation_name = operation_name ,
105107 get_next_page = lambda page : self .get (
106108 job_id ,
107109 params = GetBatchScrapeJobParams (page = page , batch_size = 100 ),
@@ -156,9 +158,10 @@ async def start_and_wait(
156158 job_id = job_start_resp .job_id
157159 if not job_id :
158160 raise HyperbrowserError ("Failed to start scrape job" )
161+ operation_name = build_operation_name ("scrape job " , job_id )
159162
160163 return await wait_for_job_result_async (
161- operation_name = f"scrape job { job_id } " ,
164+ operation_name = operation_name ,
162165 get_status = lambda : self .get_status (job_id ).status ,
163166 is_terminal_status = lambda status : status in {"completed" , "failed" },
164167 fetch_result = lambda : self .get (job_id ),
0 commit comments