Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
bastimeyer merged 3 commits into
streamlink:masterfrom
bastimeyer:remove-asyncio
Sep 29, 2024
Merged

Rewrite asyncio-based utils.processoutput code based on trio and remove pytest-asyncio dev-requirement#6208
bastimeyer merged 3 commits into
streamlink:masterfrom
bastimeyer:remove-asyncio

Conversation

@bastimeyer

Copy link
Copy Markdown
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
@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