Commit 2604409
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>
1 parent 49a5978 commit 2604409
File tree
16 files changed
+1694
-445
lines changed- scripts/populate_tox
- sentry_sdk
- integrations
- tests
- integrations/asyncio
16 files changed
+1694
-445
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
174 | | - | |
| 175 | + | |
| 176 | + | |
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| 85 | + | |
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
351 | 352 | | |
352 | 353 | | |
353 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
354 | 363 | | |
355 | 364 | | |
356 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
251 | 255 | | |
252 | 256 | | |
253 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
254 | 264 | | |
255 | 265 | | |
256 | 266 | | |
| |||
472 | 482 | | |
473 | 483 | | |
474 | 484 | | |
475 | | - | |
| 485 | + | |
476 | 486 | | |
477 | 487 | | |
478 | 488 | | |
| |||
999 | 1009 | | |
1000 | 1010 | | |
1001 | 1011 | | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
1002 | 1038 | | |
1003 | 1039 | | |
1004 | 1040 | | |
| |||
1009 | 1045 | | |
1010 | 1046 | | |
1011 | 1047 | | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
1022 | 1057 | | |
1023 | 1058 | | |
1024 | 1059 | | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
1025 | 1082 | | |
1026 | 1083 | | |
1027 | 1084 | | |
| |||
1035 | 1092 | | |
1036 | 1093 | | |
1037 | 1094 | | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
1038 | 1101 | | |
1039 | 1102 | | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
| 1103 | + | |
| 1104 | + | |
1047 | 1105 | | |
1048 | 1106 | | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
1049 | 1132 | | |
1050 | 1133 | | |
1051 | 1134 | | |
1052 | 1135 | | |
1053 | 1136 | | |
1054 | 1137 | | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
1055 | 1144 | | |
1056 | 1145 | | |
1057 | 1146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
0 commit comments