Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full timeout support #255

Merged
merged 13 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 259 additions & 37 deletions astrapy/collection.py

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion astrapy/core/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import httpx
from typing import Any, Dict, Optional, cast
from typing import Any, Dict, Optional, Union, cast

from astrapy.core.core_types import API_RESPONSE
from astrapy.core.utils import amake_request, make_request
Expand Down Expand Up @@ -32,6 +32,7 @@ def raw_api_request(
path: Optional[str],
caller_name: Optional[str],
caller_version: Optional[str],
timeout: Optional[Union[httpx.Timeout, float]],
) -> httpx.Response:
return make_request(
client=client,
Expand All @@ -44,6 +45,7 @@ def raw_api_request(
path=path,
caller_name=caller_name,
caller_version=caller_version,
timeout=timeout,
)


Expand Down Expand Up @@ -82,6 +84,7 @@ def api_request(
skip_error_check: bool,
caller_name: Optional[str],
caller_version: Optional[str],
timeout: Optional[Union[httpx.Timeout, float]],
) -> API_RESPONSE:
raw_response = raw_api_request(
client=client,
Expand All @@ -94,6 +97,7 @@ def api_request(
path=path,
caller_name=caller_name,
caller_version=caller_version,
timeout=timeout,
)
raw_response.raise_for_status()
return process_raw_api_response(
Expand All @@ -113,6 +117,7 @@ async def async_raw_api_request(
path: Optional[str],
caller_name: Optional[str],
caller_version: Optional[str],
timeout: Optional[Union[httpx.Timeout, float]],
) -> httpx.Response:
return await amake_request(
client=client,
Expand All @@ -125,6 +130,7 @@ async def async_raw_api_request(
path=path,
caller_name=caller_name,
caller_version=caller_version,
timeout=timeout,
)


Expand Down Expand Up @@ -163,6 +169,7 @@ async def async_api_request(
skip_error_check: bool,
caller_name: Optional[str],
caller_version: Optional[str],
timeout: Optional[Union[httpx.Timeout, float]],
) -> API_RESPONSE:
raw_response = await async_raw_api_request(
client=client,
Expand All @@ -175,6 +182,7 @@ async def async_api_request(
path=path,
caller_name=caller_name,
caller_version=caller_version,
timeout=timeout,
)
raw_response.raise_for_status()
return await async_process_raw_api_response(
Expand Down
Loading
Loading