From 852804ee5c24f89cc2a9416dd1977af381e3b2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Sat, 25 Jul 2026 01:26:44 +0200 Subject: [PATCH] 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 --- ytsage/core/ytsage_downloader.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ytsage/core/ytsage_downloader.py b/ytsage/core/ytsage_downloader.py index 820b12b..3799143 100644 --- a/ytsage/core/ytsage_downloader.py +++ b/ytsage/core/ytsage_downloader.py @@ -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