Skip to content

cli.output: use subprocess.DEVNULL in PlayerOutput #5242

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

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Mar 12, 2023

Instead of passing os.devnull file-handles to subprocess.Popen, use the subprocess.DEVNULL identifier for stdout/stderr streams.

This avoids ResourceWarnings in tests when the file-handles don't get closed despite never calling PlayerOutput.open(), as they were already opened in the PlayerOutput's constructor, e.g. during test collection in parametrized tests without indirect fixtures.

Also call PlayerOutput.close() in tests where a mocked player output was explicitly opened.


master

https://github.com/streamlink/streamlink/actions/runs/4394894339/jobs/7696256649#step:5:282

sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='w' encoding='UTF-8'>

PR

https://github.com/streamlink/streamlink/actions/runs/4397095519/jobs/7699992192#step:5:281

Instead of passing `os.devnull` file-handles to `subprocess.Popen`,
use the `subprocess.DEVNULL` identifier for stdout/stderr streams.

This avoids `ResourceWarning`s in tests when the file-handles don't get
closed despite never calling `PlayerOutput.open()`, as they were already
opened in the `PlayerOutput`'s constructor, e.g. during test collection
in parametrized tests without indirect fixtures.

Also call `PlayerOutput.close()` in tests where a *mocked* player output
was explicitly opened.
@gravyboat gravyboat merged commit f635705 into streamlink:master Mar 12, 2023
@bastimeyer bastimeyer deleted the cli/output/fix-devnull-filehandle branch March 12, 2023 19:36
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.

2 participants