chore: Add async shim layer for concurrency and HTTP transport#451
Draft
jsonbailey wants to merge 1 commit into
Draft
chore: Add async shim layer for concurrency and HTTP transport#451jsonbailey wants to merge 1 commit into
jsonbailey wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the async shim layer that later async slices build on. These modules are dormant — nothing in
mainimports them yet — so this PR adds no runtime surface to the synchronous SDK beyond the new (unimported) modules and their tests.This is part of the async Python SDK epic (SDK-60), shipped as a stacked series of focused PRs. SDK-2601.
What's added
ldclient/impl/shims/aio.py— async concurrency primitives:AsyncEvent,AsyncLock,AsyncRWLock,AsyncQueue,AsyncRepeatingTask,AsyncCallbackScheduler,AsyncTaskRunner,AsyncWorkerPool, plusspawn_handle/join_handle,resolve, anditerate. Each wraps a piece of fiddly asyncio plumbing the async shells would otherwise inline; the sync side uses the equivalent stdlib/SDK primitives directly, so there is no sync twin.ldclient/impl/shims/aio_transport.py— async HTTP/SSE transport over an aiohttpClientSession:make_client_session(SSL/cert/proxy setup from the SDK HTTP config),AsyncHTTPTransport(session-ownership-aware request/close), andAsyncSSEFactory(configuredAsyncSSEClientfor streaming).ldclient/impl/shims/transport_types.py—TransportResponse, the uniform response type shared by the transport shims.ldclient/testing/impl/test_shims.py— unit coverage for the concurrency primitives and the transport (SSL context application, session ownership, SSE client creation).What will consume the shims later
aio.py→ async big segments, the flag tracker, the event processor, FDv1/FDv2 polling and streaming, and the data systems.aio_transport.py→ async FDv1 streaming/polling, the event processor, and the FDv2 sources.Packaging
Introduces the
[async]optional-dependencies extra (aiohttp) and addsaiohttp+pytest-asyncioto the dev group, withasyncio_mode = "strict"so the new async tests run under pytest-asyncio in CI. No change to the eventsource pin, the redis pin, or the project version.Testing
uv run pytest ldclient/testing/impl/test_shims.py— 26 passeduv run mypy ldclient— success, no issuesuv run isort --check ldclient/pycodestyle— clean