Skip to content

Add async transport#4614

Merged
sl0thentr0py merged 43 commits intosrothh/transport-class-hierarchyfrom
srothh/async-transport
Aug 13, 2025
Merged

Add async transport#4614
sl0thentr0py merged 43 commits intosrothh/transport-class-hierarchyfrom
srothh/async-transport

Conversation

@srothh
Copy link
Contributor

@srothh srothh commented Jul 23, 2025

Add async implementation of the abstract Transport class. This transport utilizes the async task worker as well as the httpcore async functionality.

Thread Safety: As capture_envelope is registered by the client as a callback for several background threads in the sdk, which are not running the event loop, capture_envelope in the transport is made to be thread safe and allow for execution on the event loop from other threads. The same is currently not the case for flush, as there does not seem to be a usage from background threads, however if necessary, it can also be added.

HTTP2 support: Currently not activated, but from the looks of the httpcore docs it should be as simple as setting the http2 in the init of the pool to true. This likely makes sense to support, as HTTP2 shows great performance improvements with concurrent requests.

Kill: The kill method is sync, but the pool needs to be closed asynchronously. Currently, this is done by launching a task. However, the task cannot be awaited in sync code without deadlocking, therefore kill followed by an immediate loop shutdown could technically lead to resource leakage. Therefore, I decided to make kill optionally return the async task, so it can be awaited if called from an async context.

Note also that parts of the code are very similar to the HTTP2 integration, as they both use the httpcore library. Maybe in a later PR there could be a shared superclass to avoid code duplication?

GH-4582

Loading
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.

3 participants