Commit f64ada2
authored
fix: avoid retaining routing parameter instances in cache (#17961)
functools.cache keeps method arguments, including self, in its unbounded
cache. As a result, RoutingParameter instances remain alive after
routing resolution.
Use the existing instance-scoped utils.cached_property for the compiled
regex and routing key while preserving the to_regex() method API. Add a
regression test that verifies a populated cache does not retain the
instance.
Testing:
- pytest
packages/gapic-generator/tests/unit/schema/wrappers/test_routing.py -q
(Python 3.10 and 3.14)
- pytest packages/gapic-generator/tests/unit/schema/wrappers -q (Python
3.14)1 parent bd1e224 commit f64ada2
2 files changed
Lines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
1289 | 1288 | | |
1290 | 1289 | | |
1291 | 1290 | | |
1292 | | - | |
1293 | | - | |
1294 | | - | |
| 1291 | + | |
| 1292 | + | |
1295 | 1293 | | |
1296 | 1294 | | |
1297 | | - | |
1298 | | - | |
1299 | | - | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
1300 | 1299 | | |
1301 | 1300 | | |
1302 | 1301 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
146 | 149 | | |
147 | 150 | | |
148 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
149 | 167 | | |
150 | 168 | | |
151 | 169 | | |
| |||
0 commit comments