Skip to content

Rewrite asyncio-based utils.processoutput code based on trio and remove pytest-asyncio dev-requirement #6208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 29, 2024

Conversation

bastimeyer
Copy link
Member

The utils.processoutput utility is currently used by FFMPEGMuxer to validate the ffmpeg binary by reading its version string and compile flags.

This was previously done using asyncio from the stdlib, hence the requirement of pytest-asyncio in the tests. The only other tests making use of the asyncio run loop were the CLI's StreamRunner tests (just for convenience though) and the handshake test utilities for making assertions about thread synchronization.

Since Streamlink's webbrowser API is based on trio, it doesn't make sense mixing async run loops from two different libs. On Windows, this also raises a warning when running Streamlink's testsuite.

The rewritten utils.processoutput module and its tests are now much cleaner and easier to read due to trio's structured concurrency. No other changes were made here apart from gracefully terminating the spawned subprocess now, instead of just killing it when all tasks were completed (in case it was still running).

A nice side effect of the pytest-asyncio removal is that it reduces the run time of the whole testsuite on my Arch Linux host system from 9s to 7s, and in my W10 VM from 35s to 29s.

I will have another look at the diff later before merging, in case I missed something.

@bastimeyer

This comment was marked as outdated.

@bastimeyer bastimeyer marked this pull request as draft September 29, 2024 16:51
- Replace asyncio-based code with trio-based code
- Gracefully terminate process instead of just killing it
- Run actual subprocess in tests
@bastimeyer bastimeyer marked this pull request as ready for review September 29, 2024 19:09
@bastimeyer bastimeyer merged commit 1d5b25b into streamlink:master Sep 29, 2024
25 checks passed
@bastimeyer bastimeyer deleted the remove-asyncio branch September 29, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant