You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add experimental async transport (port of PR #4572) (#5646)
Add an experimental async transport using httpcore's async backend,
enabled via `_experiments={"transport_async": True}`.
This is a manual port of PR #4572 (originally merged into `potel-base`)
onto the current `master` branch.
## Key changes
- **transport.py**: Refactor `BaseHttpTransport` into
`HttpTransportCore`
(shared base) + `BaseHttpTransport` (sync) + `AsyncHttpTransport`
(async, conditional on `httpcore[asyncio]`). Extract shared helpers:
`_handle_request_error`, `_handle_response`, `_update_headers`,
`_prepare_envelope`. Update `make_transport()` to detect the
`transport_async` experiment.
- **worker.py**: Add `Worker` ABC base class and `AsyncWorker`
implementation using `asyncio.Queue` / `asyncio.Task`.
- **client.py**: Add `close_async()` / `flush_async()` with
async-vs-sync
transport detection. Extract `_close_components()` /
`_flush_components()`.
- **api.py**: Expose `flush_async()` as a public API.
- **integrations/asyncio.py**: Patch `loop.close` to flush pending
events
before shutdown. Skip span wrapping for internal Sentry tasks.
- **utils.py**: Add `is_internal_task()` / `mark_sentry_task_internal()`
via ContextVar for async task filtering.
- **setup.py**: Add `"asyncio"` extras_require
(`httpcore[asyncio]==1.*`).
- **config.py / tox.ini**: Widen anyio to `>=3,<5` for httpx and
FastAPI.
## Notes
- `tox.ini` was manually edited (the generation script requires a
free-threaded Python interpreter). A full regeneration should be done
before merge.
Refs: GH-4568
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
0 commit comments