cli: threaded read_stream()#4974
Conversation
1924116 to
3b5f8b9
Compare
Rewrite `streamlink_cli.main.read_stream()`, refactor progress thread data feeding, and move player polling into a separate thread which closes the reader once the player process terminates or gets killed. This fixes the player polling issue, or rather the detection of its broken pipe while reading the stream, as stream read calls can stall for various reasons, e.g. due to segmented streams or the filtering of stream data which pauses the stream output and disables any timeouts.
3b5f8b9 to
1702f1a
Compare
|
I've updated and rewritten the PR changes. Please check. The player polling now stops immediately via a Still no tests though. I made some efforts, but it's a lot of boilerplate code dealing with three threads (main test thread, CLI "main" read thread and player polling thread) and testing all the timings between all possible scenarios. |
|
Going to close this... I will open a new PR with a complete code refactor of the |
Rewrite
streamlink_cli.main.read_stream(), refactor progress thread data feeding, and move player polling into a separate thread which closes the reader once the player process terminates or gets killed.This fixes the player polling issue, or rather the detection of its broken pipe while reading the stream, as stream read calls can stall for various reasons, e.g. due to segmented streams or the filtering of stream data which pauses the stream output and disables any timeouts.
Resolves #4642
As mentioned in #4642, there are still no tests written for
read_stream(). I will be thinking about writing ones for a bit first before I'm going to mark this PR as ready. I also haven't fully tested this in production yet, only with a simple player stdin pipe as output, and only on my Linux system.