Skip to content

🐛 fix(seed): wait for workers before cleanup - #3644

Merged
gaborbernat merged 5 commits into
pypa:mainfrom
gaborbernat:fix/interrupt-seed-cleanup
Nov 20, 2026
Merged

gaborbernat merged 5 commits into
pypa:mainfrom
gaborbernat:fix/interrupt-seed-cleanup

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Before this fix, FromAppData.run() joined seed threads only on the normal path. An interrupt could reach session cleanup while a worker was using temporary app-data, leaving a folder after virtualenv exited. The seeder now waits for its workers before cleanup and then re-raises the interrupt. Fixes #3636.

Worker lifetime during interruption

Both wheel lookup and image installation run in an executor. Each worker records completion after its task returns. If an interrupt arrives while a task is being submitted, the seeder retries that task with a guard that runs it once, then waits for its completion. Repeated interrupts during the wait cannot release app-data while a task is active. If the executor rejects a submission, the task runs on the caller thread.

sequenceDiagram
    participant S as Session
    participant W as Seed worker
    participant A as Temporary app-data
    rect rgb(255, 214, 214)
        S->>+W: before: start seed work
        S-->>S: interrupt
        S->>A: remove app-data
        W-->>-S: work finishes later
    end
    rect rgb(216, 243, 220)
        S->>+W: now: start seed work
        S-->>S: interrupt
        S->>W: wait for task completion
        W-->>-S: work finishes
        S->>A: remove app-data
    end
Loading

Behavior changes

When temporary app-data is in use, an interrupt during seed lookup or installation waits for active workers before the session removes that directory. The temporary-cache copy guard continues to select copies instead of symlinks.

Reported by @oss-scanner: ANT-2026-02O7K288.

@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 06:33
@gaborbernat
gaborbernat force-pushed the fix/interrupt-seed-cleanup branch 3 times, most recently from d4225f9 to 654a40e Compare November 20, 2026 08:34
An interrupt during seeding could close temporary app-data while a worker
was still writing to it. Keep the session open until every worker finishes,
including after repeated interrupts.

Fixes pypa#3636
@gaborbernat
gaborbernat force-pushed the fix/interrupt-seed-cleanup branch from 654a40e to 05a4638 Compare November 20, 2026 09:09
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 09:49
@gaborbernat
gaborbernat merged commit a366d3c into pypa:main Nov 20, 2026
81 checks passed
@gaborbernat
gaborbernat deleted the fix/interrupt-seed-cleanup branch November 23, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interrupted seeding can leave temporary app-data behind

1 participant