Skip to content

FIX make file output safe across event loops - #2664

Merged
Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
romanlutz:romanlutz-daily-audit-2026-09-15
Sep 15, 2026
Merged

Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
romanlutz:romanlutz-daily-audit-2026-09-15

Conversation

@romanlutz

Copy link
Copy Markdown
Contributor

Description

FileSink currently uses an asyncio.Lock, which becomes bound to the first event loop that contends on it. Reusing the same sink from a later asyncio.run(...) call can therefore raise a cross-event-loop RuntimeError.

This change moves serialization into the worker thread with threading.Lock, so the event loop remains non-blocking while one sink can safely serialize file writes across event loops. It also removes an unreferenced ecosystem SVG discovered during the audit and updates the output contributor guidance to match the locking design.

Tests and Documentation

  • Added a deterministic two-event-loop, two-contender regression test using events rather than sleeps. It verifies exact write ordering, terminal completion, lock cleanup, non-duplicated output, and absence of an early second write.
  • Full unit suite: 17,543 passed, 8 skipped.
  • Final Crescendo module after syncing main: 84 passed.
  • FileSink tests: 13 passed.
  • Ruff check and format check passed.
  • Full ty check pyrit passed with no diagnostics.
  • uv lock --check, compileall, documentation TOC/orphan validation, and pre-commit hooks passed.
  • JupyText was not run because no notebook source or notebook file changed.

Serialize file writes inside worker threads so one sink can be reused across event loops. Add deterministic contended-write regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 21bf73f6-4b26-4f5f-bb22-01fa72e49186
Remove the unreferenced Microsoft SVG added with the landing-page ecosystem artwork.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 21bf73f6-4b26-4f5f-bb22-01fa72e49186
Comment thread pyrit/output/sink.py
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 21bf73f6-4b26-4f5f-bb22-01fa72e49186
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Sep 15, 2026
Merged via the queue into microsoft:main with commit f4de826 Sep 15, 2026
49 checks passed
@romanlutz
Roman Lutz (romanlutz) deleted the romanlutz-daily-audit-2026-09-15 branch September 15, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants