Repository navigation
fix(calibration): reap timed-out image fetch workers - #3855
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3854.
A server that trickles response headers kept a daemon request thread and socket alive after
total_timeout. Each network attempt now runs in a fresh subprocess; timeout or caller interruption kills and reaps it before returning. Successful and failed attempts also close their IPC pipes. The change is 271 insertions and 174 deletions across four files, including tests and the updated reference page.The caller retains retries, backoff, image decoding and pixel limits. The worker retains requests' status/error handling and streaming byte limit. No private socket inspection or background fetch/watchdog thread remains.
flowchart TD A["load_image_from_url: absolute deadline"] --> B["_download_image_bytes: launch fresh interpreter"] B --> C["_image_fetch_worker: requests.get and bounded body read"] B --> D["communicate: remaining deadline"] C --> D D -- timeout or caller interruption --> E["kill child; drain pipes; reap"] E --> F["ImageFetchError or caller interruption"] D -- bytes --> G["Check pixel limit; decode; recheck deadline"] D -- retryable failure --> H["Backoff within shared deadline"] H --> B D -- permanent failure --> F classDef fail fill:#f8d7da,stroke:#b02a37,color:#000; class E,F fail;d831ba08gptqmodel/utils/image.py:160–213: daemon thread stops being awaited but cannot interruptrequests.getimage.py:185–208: response availability races cancellationimage.py:284–293: watchdog accesses private response socketsCommitted flow and lifecycle contract, linked from README.
Validation:
python -m pytest tests/test_image_fetch.py -q -o log_cli=false --disable-warnings --maxfail=1: 28 passed on Python 3.14t with the GIL disabled.bash format/check.sh(complete repository Ruff gate),git diff --check, and Mermaid fence validation pass.Tradeoff: each network attempt pays fresh-interpreter startup, which counts against
total_timeout. The worker executes the installed file withrunpy.run_path, preserving user-site andPYTHONPATHdependency discovery without importing the GPT-QModel model registry or initializing accelerator state. Process teardown adds a small scheduling/reaping interval. Pillow decoding remains in the caller with deadline checks before/after; this change does not make the decoder interruptible.