Allow streamlink to exit faster when using Ctrl-C#1658
Merged
Conversation
Member
Author
|
Only works for Python 3+, hence the build errors. Updated with alternative version that clears |
The segmented stream downloader uses a threadpool to allow multiple segments to be downloaded simultaneously. The thread pool installs an atexit hook so that causes them to complete their current tasks, this means that if segments are still downloading streamlink will continue running until the segments are downloading. The exit hook loops `concurrent.futures.thread._threads_queues` and joins all the threads in that queue. By clearing the queue we can avoid joining and exit earlier - the threads being killed shouldn't cause any consistency issues as they are just downloading and not writing/updating anything (or, they shouldn't be).
06c670e to
d285e3a
Compare
Codecov Report
@@ Coverage Diff @@
## master #1658 +/- ##
==========================================
+ Coverage 33.17% 33.18% +0.01%
==========================================
Files 229 229
Lines 12898 12912 +14
==========================================
+ Hits 4279 4285 +6
- Misses 8619 8627 +8 |
This was referenced May 16, 2018
Member
Author
|
@gravyboat if you get time to look at this one as well. |
Member
|
Looks good to me, nice fix @beardypig. |
mkbloke
pushed a commit
to mkbloke/streamlink
that referenced
this pull request
Aug 18, 2020
Allow streamlink to exit faster when using Ctrl-C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The segmented stream downloader uses a threadpool to allow multiple segments to be downloaded simultaneously. The thread pool installs an atexit hook so that causes them to complete their current tasks, this means that if segments are still downloading streamlink will continue running until the segments are downloading.
By unregistering this atexit hook (because there aren't any consistency issues) the exit time can be sped up in some cases.
See #521.