Actually suspend the download process group on pause

Pause only stopped the stdout reader loop; yt-dlp kept transferring at
full rate until the pipe buffer filled, consuming bandwidth while the
UI claimed the download was paused. Send SIGSTOP/SIGCONT to the whole
process group (yt-dlp and its ffmpeg children) on Unix. Windows has no
equivalent signal; the limitation is documented in the helper.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-07-25 01:26:44 +02:00
parent 5064b38315
commit 852804ee5c
+15
View File
@@ -839,9 +839,24 @@ class DownloadThread(QThread):
def pause(self) -> None:
self.paused = True
self._signal_process_group(signal.SIGSTOP if sys.platform != "win32" else None)
def resume(self) -> None:
self.paused = False
self._signal_process_group(signal.SIGCONT if sys.platform != "win32" else None)
def _signal_process_group(self, sig: Optional[int]) -> None:
"""Send a signal to yt-dlp's whole process group (yt-dlp + ffmpeg children).
On Windows there is no SIGSTOP/SIGCONT; pausing there only stops output
consumption, which is a known limitation.
"""
if sig is None or not self.process:
return
try:
os.killpg(os.getpgid(self.process.pid), sig)
except (ProcessLookupError, PermissionError, OSError) as e:
logger.debug(f"Could not signal process group: {e}")
def cancel(self) -> None:
self.cancelled = True