Skip to content

chore: Add async shim layer for concurrency and HTTP transport#451

Draft
jsonbailey wants to merge 1 commit into
mainfrom
jb/sdk-2601/async-shim-layer
Draft

chore: Add async shim layer for concurrency and HTTP transport#451
jsonbailey wants to merge 1 commit into
mainfrom
jb/sdk-2601/async-shim-layer

Conversation

@jsonbailey

Copy link
Copy Markdown
Contributor

Summary

Adds the async shim layer that later async slices build on. These modules are dormant — nothing in main imports 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, plus spawn_handle/join_handle, resolve, and iterate. 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 aiohttp ClientSession: make_client_session (SSL/cert/proxy setup from the SDK HTTP config), AsyncHTTPTransport (session-ownership-aware request/close), and AsyncSSEFactory (configured AsyncSSEClient for streaming).
  • ldclient/impl/shims/transport_types.pyTransportResponse, 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 adds aiohttp + pytest-asyncio to the dev group, with asyncio_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 passed
  • Full unit suite (database tests skipped) — 1041 passed, 194 skipped
  • uv run mypy ldclient — success, no issues
  • uv run isort --check ldclient / pycodestyle — clean

@jsonbailey jsonbailey changed the title feat: Add async shim layer for concurrency and HTTP transport chore: Add async shim layer for concurrency and HTTP transport Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant