Repository navigation
Serialize concurrent calls to shared native face detectors - #1756
Merged
serengil merged 2 commits intoNov 16, 2026
Merged
Conversation
serengil
approved these changes
Nov 16, 2026
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.
Tickets
N/A
What has been done
Cached detector instances are shared across requests, but MediaPipe graphs and OpenCV Haar classifiers keep mutable native inference state. Overlapping calls can mix detections, raise packet-timestamp errors, or corrupt the classifier's image buffers.
Serialize MediaPipe
processcalls and OpenCV face/eye classification calls with a lock owned by each detector instance. Separate instances can still run concurrently, and native errors release the lock. Update existing detector fixtures to use their constructors so their inference locks are initialized.How to test
python -m pytest -q tests/unit/test_mediapipe_concurrent_inference.py tests/unit/test_mediapipe_color_order.py tests/unit/test_opencv_concurrent_inference.py tests/unit/test_face_crop_bounds.py tests/unit/test_ssd_concurrent_inference.py tests/unit/test_ssd_opencv_version.py