← Back to Pull requests

fix(py): release the GIL while a build runs, so progress callbacks do not deadlock #2954

Closed
unknown closed this pull request without merging on Nov 17, 2026 19:18 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 18:00 UTC
Author

Fixes #2952.

What

RenderedVariant.run_build(..., progress_callback=cb) hangs since 0.77.0. Since #2843 every build runs on its own tokio task, so log events reach the Python callback from a runtime worker thread, where Python::attach waits for the GIL. The caller kept the GIL while blocking on the runtime, so neither side could continue.

build_rendered_variant_py now releases the GIL (py.detach) while the build runs. The log capture is unchanged and still runs on the calling thread; only the wait happens without the GIL.

Side effects:

  • Other Python threads keep running during a build (in the issue, a heartbeat thread stopped).

  • The callback is called from a tokio worker thread rather than the thread that called run_build. That has been the case since #2843 (it is why the hang happens); calls are still serialized by the GIL.
  • Tests

  • New test_run_build_with_progress_callback: builds a small recipe with a callback in a child process with a 120 s timeout, so a deadlock fails the test instead of hanging the suite, and checks that the callback received events. On main it times out; with this PR it passes.

  • The reproducer from #2952 (macOS arm64): hangs on 0.77.0 (pkgs/main) and on main (7c0a5e1d), completes in about 1 s with this PR. Without a callback, all of them complete.

  • py-rattler-build test suite (210 passed, 5 skipped), cargo fmt --check, cargo clippy --all-targets -- -D warnings, ruff check and ruff format --check pass locally on macOS.
  • ---

    This PR (code and description) was AI-generated with Claude Opus 5.5 (claude-opus-5-5) and reviewed before opening.

    🤖 Generated with Claude Code

    Diff: 211 lines (+158 / -53) across 2 files Reviewer: wolfv Review duration: 77m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 211 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.320
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2954"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.5% (MEDIUM) · Higher = larger blast radius
    36.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.4% · Safe to merge
    14.4%