Repository navigation
Commit 89e54e2
authored
test(core): drop vacuous URLError wait-strategy case (#1116)
`HttpWaitStrategy` leaks a file descriptor per failed request. A wait
strategy polls, so a container
that takes a while to become healthy leaks one descriptor per attempt,
and a suite waiting on several
containers can exhaust the limit.
`urlopen` is used in a `with`, so the success path closes. `HTTPError`
is the leak: it is both an
exception and a response file object, so raising it hands back an open
descriptor that the `except`
clause discards without closing.
`src/testcontainers/core/wait_strategies.py` now splits the handler.
`HTTPError` is handled inside
`with e:`, which closes the wrapped response on the way out, and
`URLError`, which carries no file
object, keeps the plain path.
Behaviour is otherwise unchanged: both still go to `_handle_http_error`
and the strategy retries as
before.
The test asserts no descriptors are left open across repeated failing
probes.
Fixes #11151 parent 71bd0f4 commit 89e54e2
2 files changed
Lines changed: 34 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
422 | 427 | | |
423 | 428 | | |
424 | 429 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
361 | 364 | | |
362 | 365 | | |
363 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
364 | 392 | | |
365 | 393 | | |
366 | 394 | | |
| |||
0 commit comments