Skip to content

refactor: extract aiohttp transport - #470

Open
alexanto wants to merge 1 commit into
refactor/extract-requests-transportfrom
refactor/extract-aiohttp-transport
Open

alexanto wants to merge 1 commit into
refactor/extract-requests-transportfrom
refactor/extract-aiohttp-transport

Conversation

@alexanto

@alexanto alexanto commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

async counterpart of #469

@alexanto
alexanto added this pull request to stack #468 November 3, 2026 14:23
@gastonfournier gastonfournier moved this from New to In Progress in Issues and PRs Nov 4, 2026
@alexanto
alexanto requested a balanced review from Copilot November 5, 2026 13:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Malformed UTF-8 can overwrite cached feature state with altered values, and truncated error-response bodies can bypass configured retries.

2 open issues
What changed in this PR

Extracts aiohttp request handling into a dedicated async transport, mirroring the synchronous transport separation in #469 and preparing the async client for custom HTTP transports.

Changes:

  • Adds an AsyncTransport protocol and a pooled AiohttpTransport implementation.
  • Routes async API requests through an injectable transport with explicit ownership and cleanup.
  • Adds transport tests and updates API-client tests for the new structure.
File Description
UnleashClient/​_transport.py Defines the async transport protocol.
UnleashClient/​_async_unleash_api_client.py Delegates HTTP operations and manages default transport ownership.
UnleashClient/​_aiohttp_transport.py Implements aiohttp requests, timeouts, and session lifecycle.
tests/​unit_tests/​test_async_unleash_api_client.py Tests transport injection, request construction, and cleanup ownership.
tests/​unit_tests/​test_async_metrics.py Updates the lazy-session assertion for transport-owned sessions.
tests/​unit_tests/​test_aiohttp_transport.py Tests requests, responses, errors, session reuse, and closure.

Review effort: Balanced

_fetched_status(raw_state),
)
resp = await self._transport.execute(request)
except RETRYABLE_ERRORS:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this goes away in #472

FetchStatus.NOT_CHANGED,
)

raw_state = _text(resp)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is worth fixing but will do in a separate PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants