fix: avoid blocking audio format probes - #10055
Conversation
There was a problem hiding this comment.
Independent validation at e871599 on Windows:
pytest tests/test_media_utils.py -q: 55 passed (one audioop deprecation warning).- Ruff check and format --check on both changed files: passed.
- Added a local diagnostic wrapper around the real
_get_audio_magic_typerecordingthreading.get_ident(), without replacingasyncio.to_thread. The off-loop-thread assertion fails on base 7ec39bd and the off-loop-thread assertion passes on this head (1 test). The wrapper still invokes the original detector on a WAV fixture.
This confirms actual thread offloading in addition to the new mocked-call unit test. The existing Ogg/Opus no-subprocess regression also passes as part of the 55 tests. Scope: media utility tests and the probe thread boundary, not a full-suite/real-codec integration run or a claim that every filesystem operation in the helper is asynchronous.
|
@kilisamemarisaaa Thanks for the independent validation. The targeted media tests and Ruff checks passing, together with the real thread-ID check, confirm that the magic-byte probe is actually offloaded from the event-loop thread and that the Ogg/Opus fast path remains intact. No code changes are needed from this review. |
Summary
asyncio.to_threadso audio conversion does not block the event loopContext
Follow-up to #9329. The current
masterincludes the file-content check from #9612, but the probe still performs synchronous file I/O insideconvert_audio_format, and Ogg Opus files are needlessly re-encoded when Ogg output is requested. This PR keeps the correctness fix on the latestmasterwhile addressing those remaining cases.Validation
Per request, local tests were not run.
Summary by Sourcery
Keep audio conversion responsive by offloading format probes and preserving compatible Ogg Opus inputs.
Bug Fixes:
Tests: