Skip to content

Stop test apps' background threads, and floor pillow-heif at 1.2.1 - #218

Merged
abrignoni merged 5 commits into
mainfrom
fix/stop-app-threads-between-tests
Sep 27, 2026
Merged

abrignoni merged 5 commits into
mainfrom
fix/stop-app-threads-between-tests

Conversation

@abrignoni

@abrignoni abrignoni commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Fixes two ways the full suite fails on macOS that CI does not show.

  • Background threads: every app a test built kept its snapshot loop and Find similar indexer running for the rest of the suite. With numpy on OpenBLAS, a fork while a leftover indexer was inside OpenBLAS deadlocked the run. Apps now have state["shutdown"](), the indexer answers a stop at once, the snapshot loop survives a case closed under it, and conftest.py shuts every app down and fails a test that leaks either thread.
  • CaseDB.close() now takes the lock every query takes. Closing a case while another thread queried it segfaulted on Linux CI.
  • HEIC: pillow-heif below 1.2.1 segfaults encoding once OpenCV is loaded. The dev extra now needs 1.2.1.

All three are written up in the cross-platform rules.

🤖 Generated with Claude Code

abrignoni and others added 5 commits September 27, 2026 11:17
create_app starts a snapshot loop, and an ingest through the app starts
the Find similar indexer. Nothing ever stopped either in a test, so a
full run carried them into every later test: by the test_pipeline ingest
tests, 82 snapshot loops and six indexers were alive. On macOS with a
numpy built on OpenBLAS, a job forking the video worker while a leftover
indexer was inside a threaded OpenBLAS call deadlocked in OpenBLAS's
fork handler with the GIL held, and the run never finished. With numpy on
Accelerate it finished, but reached 145 threads and 3.3 GB on the way,
and seven snapshot loops died on cases closed under them.

- state["shutdown"]() stops the snapshot loop and the indexer and waits
  for both. The case stays open.
- The indexer waits on its stop event instead of sleeping, so a stop no
  longer waits out up to two seconds.
- The snapshot loop skips a case closed while the app still holds it,
  instead of ending on ProgrammingError.
- tests/conftest.py wraps create_app (and gleapp.desktop's own import of
  it), shuts every app down at teardown, and fails a test that leaves
  either thread running.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On macOS, pillow-heif below 1.2.1 segfaults while encoding a HEIF once
OpenCV has been imported: both bundle an x265, and pillow-heif's weak
rdoQuant symbols bind to OpenCV's copy. In a full run an earlier test has
always loaded cv2, so the HEIC LAVA test crashed there and passed alone.
The old floor, 1.0, still admitted affected releases (1.0.0 through
1.2.0). Upstream fixed it in 1.2.1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two cross-platform notes with their measurements: pillow-heif below 1.2.1
crashing on macOS once OpenCV is loaded, and the suite's app threads that
outlived their tests and deadlocked a fork on OpenBLAS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first version of the snapshot-loop test closed a case while the
loop, polling every 0.02 s, was inside get_meta on the same connection.
get_meta holds CaseDB.lock and close() did not, and the Linux CI job
segfaulted. close() now takes the lock, so it waits for a query in
flight, and a query after it raises ProgrammingError.

The loop test now closes the case while it is clean, so the loop only
reads the flag, and dirties it afterwards. A new test holds the lock in
one thread and checks that close() in another waits for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@abrignoni
abrignoni enabled auto-merge September 27, 2026 15:30
@abrignoni
abrignoni merged commit 29c5546 into main Sep 27, 2026
12 checks passed
@abrignoni
abrignoni deleted the fix/stop-app-threads-between-tests branch September 27, 2026 18:46
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.

1 participant