Skip to content

Commit 5fba692

Browse files
Centralize paginated manager terminal status polling
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent d100327 commit 5fba692

File tree

15 files changed

+197
-19
lines changed

15 files changed

+197
-19
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ This runs lint, format checks, compile checks, tests, and package build.
101101
- `tests/test_job_fetch_helper_boundary.py` (centralization boundary enforcement for retry/paginated-fetch helper primitives),
102102
- `tests/test_job_fetch_helper_usage.py` (shared retry/paginated-fetch defaults helper usage enforcement),
103103
- `tests/test_job_pagination_helper_usage.py` (shared scrape/crawl pagination helper usage enforcement),
104+
- `tests/test_job_poll_helper_boundary.py` (centralization boundary enforcement for terminal-status polling helper primitives),
105+
- `tests/test_job_poll_helper_usage.py` (shared terminal-status polling helper usage enforcement),
104106
- `tests/test_job_start_payload_helper_usage.py` (shared scrape/crawl start-payload helper usage enforcement),
105107
- `tests/test_job_wait_helper_boundary.py` (centralization boundary enforcement for wait-for-job helper primitives),
106108
- `tests/test_job_wait_helper_usage.py` (shared wait-for-job defaults helper usage enforcement),

hyperbrowser/client/managers/async_manager/crawl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from typing import Optional
22

33
from hyperbrowser.models.consts import POLLING_ATTEMPTS
4-
from ...polling import (
5-
poll_until_terminal_status_async,
4+
from ..job_poll_utils import (
5+
poll_job_until_terminal_status_async as poll_until_terminal_status_async,
66
)
77
from ..job_fetch_utils import (
88
collect_paginated_results_with_defaults_async,

hyperbrowser/client/managers/async_manager/scrape.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from typing import Optional
22

33
from hyperbrowser.models.consts import POLLING_ATTEMPTS
4-
from ...polling import (
5-
poll_until_terminal_status_async,
4+
from ..job_poll_utils import (
5+
poll_job_until_terminal_status_async as poll_until_terminal_status_async,
66
)
77
from ..job_fetch_utils import (
88
collect_paginated_results_with_defaults_async,

hyperbrowser/client/managers/async_manager/web/batch_fetch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
read_page_current_batch,
2323
read_page_total_batches,
2424
)
25-
from ....polling import (
26-
poll_until_terminal_status_async,
25+
from ...job_poll_utils import (
26+
poll_job_until_terminal_status_async as poll_until_terminal_status_async,
2727
)
2828
from ...response_utils import parse_response_model
2929
from ...start_job_utils import build_started_job_context

hyperbrowser/client/managers/async_manager/web/crawl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
read_page_current_batch,
2323
read_page_total_batches,
2424
)
25-
from ....polling import (
26-
poll_until_terminal_status_async,
25+
from ...job_poll_utils import (
26+
poll_job_until_terminal_status_async as poll_until_terminal_status_async,
2727
)
2828
from ...response_utils import parse_response_model
2929
from ...start_job_utils import build_started_job_context
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from typing import Awaitable, Callable, Optional
2+
3+
from ..polling import poll_until_terminal_status, poll_until_terminal_status_async
4+
5+
6+
def poll_job_until_terminal_status(
7+
*,
8+
operation_name: str,
9+
get_status: Callable[[], str],
10+
is_terminal_status: Callable[[str], bool],
11+
poll_interval_seconds: float,
12+
max_wait_seconds: Optional[float],
13+
max_status_failures: int,
14+
) -> str:
15+
return poll_until_terminal_status(
16+
operation_name=operation_name,
17+
get_status=get_status,
18+
is_terminal_status=is_terminal_status,
19+
poll_interval_seconds=poll_interval_seconds,
20+
max_wait_seconds=max_wait_seconds,
21+
max_status_failures=max_status_failures,
22+
)
23+
24+
25+
async def poll_job_until_terminal_status_async(
26+
*,
27+
operation_name: str,
28+
get_status: Callable[[], Awaitable[str]],
29+
is_terminal_status: Callable[[str], bool],
30+
poll_interval_seconds: float,
31+
max_wait_seconds: Optional[float],
32+
max_status_failures: int,
33+
) -> str:
34+
return await poll_until_terminal_status_async(
35+
operation_name=operation_name,
36+
get_status=get_status,
37+
is_terminal_status=is_terminal_status,
38+
poll_interval_seconds=poll_interval_seconds,
39+
max_wait_seconds=max_wait_seconds,
40+
max_status_failures=max_status_failures,
41+
)

hyperbrowser/client/managers/sync_manager/crawl.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from typing import Optional
22

33
from hyperbrowser.models.consts import POLLING_ATTEMPTS
4-
from ...polling import (
5-
poll_until_terminal_status,
6-
)
4+
from ..job_poll_utils import poll_job_until_terminal_status as poll_until_terminal_status
75
from ..job_fetch_utils import (
86
collect_paginated_results_with_defaults,
97
fetch_job_result_with_defaults,

hyperbrowser/client/managers/sync_manager/scrape.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from typing import Optional
22

33
from hyperbrowser.models.consts import POLLING_ATTEMPTS
4-
from ...polling import (
5-
poll_until_terminal_status,
6-
)
4+
from ..job_poll_utils import poll_job_until_terminal_status as poll_until_terminal_status
75
from ..job_fetch_utils import (
86
collect_paginated_results_with_defaults,
97
fetch_job_result_with_defaults,

hyperbrowser/client/managers/sync_manager/web/batch_fetch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
read_page_current_batch,
2323
read_page_total_batches,
2424
)
25-
from ....polling import (
26-
poll_until_terminal_status,
25+
from ...job_poll_utils import (
26+
poll_job_until_terminal_status as poll_until_terminal_status,
2727
)
2828
from ...response_utils import parse_response_model
2929
from ...start_job_utils import build_started_job_context

hyperbrowser/client/managers/sync_manager/web/crawl.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
read_page_current_batch,
2323
read_page_total_batches,
2424
)
25-
from ....polling import (
26-
poll_until_terminal_status,
27-
)
25+
from ...job_poll_utils import poll_job_until_terminal_status as poll_until_terminal_status
2826
from ...response_utils import parse_response_model
2927
from ...start_job_utils import build_started_job_context
3028

0 commit comments

Comments
 (0)