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

Skip to content

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

Merged
gravyboat merged 1 commit into
streamlink:masterfrom
bastimeyer:cli/output/fix-devnull-filehandle
Mar 12, 2023
Merged

cli.output: use subprocess.DEVNULL in PlayerOutput#5242
gravyboat merged 1 commit into
streamlink:masterfrom
bastimeyer:cli/output/fix-devnull-filehandle

Conversation

@bastimeyer

@bastimeyer bastimeyer commented Mar 12, 2023

Copy link
Copy Markdown
Member

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