-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy path_consts.py
More file actions
51 lines (37 loc) · 1.78 KB
/
_consts.py
File metadata and controls
51 lines (37 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from __future__ import annotations
from datetime import timedelta
from typing import Any
from apify_client._models import ActorJobStatus
JsonSerializable = str | int | float | bool | None | dict[str, Any] | list[Any]
"""Type for representing json-serializable values. It's close enough to the real thing supported by json.parse.
It was suggested in a discussion with (and approved by) Guido van Rossum, so I'd consider it correct enough.
"""
DEFAULT_API_URL = 'https://api.apify.com'
"""Default base URL for the Apify API."""
API_VERSION = 'v2'
"""Current Apify API version."""
DEFAULT_TIMEOUT = timedelta(seconds=360)
"""Default request timeout."""
DEFAULT_MAX_RETRIES = 8
"""Default maximum number of retries for failed requests."""
DEFAULT_MIN_DELAY_BETWEEN_RETRIES = timedelta(milliseconds=500)
"""Default minimum delay between retries."""
DEFAULT_WAIT_FOR_FINISH = timedelta(seconds=999999)
"""Default maximum wait time for job completion (effectively infinite)."""
DEFAULT_WAIT_WHEN_JOB_NOT_EXIST = timedelta(seconds=3)
"""How long to wait for a job to exist before giving up."""
FAST_OPERATION_TIMEOUT = timedelta(seconds=5)
"""Timeout for fast, idempotent operations (e.g., GET, DELETE)."""
STANDARD_OPERATION_TIMEOUT = timedelta(seconds=30)
"""Timeout for operations that may take longer (e.g., list operations, batch operations)."""
TERMINAL_STATUSES = frozenset(
{
ActorJobStatus.SUCCEEDED,
ActorJobStatus.FAILED,
ActorJobStatus.TIMED_OUT,
ActorJobStatus.ABORTED,
}
)
"""Set of terminal Actor job statuses that indicate the job has finished."""
OVERRIDABLE_DEFAULT_HEADERS = {'Accept', 'Authorization', 'Accept-Encoding', 'User-Agent'}
"""Headers that can be overridden by users, but will trigger a warning if they do so, as it may lead to API errors."""