Bug
YouTube search crashes on Windows with:
AttributeError: module 'os' has no attribute 'killpg'
Steps to reproduce
- Run
last30days.py on Windows (Python 3.12)
- YouTube source is enabled (yt-dlp installed)
- Any topic triggers the crash during search or transcript fetch
Root cause
Two issues in scripts/lib/youtube_yt.py:
-
os.killpg() (lines 199, 321) — UNIX-only, does not exist on Windows. Called inside except subprocess.TimeoutExpired to kill the process group. On Windows this raises AttributeError before the except (ProcessLookupError, PermissionError, OSError) fallback can catch it.
-
os.setsid (lines 185, 307) — the hasattr(os, 'setsid') guard correctly sets preexec_fn=None on Windows, but os.killpg calls downstream still crash.
Fix
- Guard
os.killpg with hasattr(os, 'killpg'), falling back to proc.kill() on Windows
- Use
CREATE_NEW_PROCESS_GROUP creationflags on Windows instead of preexec_fn=os.setsid
Environment
- Windows 10/11, Python 3.12
- yt-dlp installed and working
- last30days v2.9.2
I have a fix ready and can submit a PR.
Bug
YouTube search crashes on Windows with:
Steps to reproduce
last30days.pyon Windows (Python 3.12)Root cause
Two issues in
scripts/lib/youtube_yt.py:os.killpg()(lines 199, 321) — UNIX-only, does not exist on Windows. Called insideexcept subprocess.TimeoutExpiredto kill the process group. On Windows this raisesAttributeErrorbefore theexcept (ProcessLookupError, PermissionError, OSError)fallback can catch it.os.setsid(lines 185, 307) — thehasattr(os, 'setsid')guard correctly setspreexec_fn=Noneon Windows, butos.killpgcalls downstream still crash.Fix
os.killpgwithhasattr(os, 'killpg'), falling back toproc.kill()on WindowsCREATE_NEW_PROCESS_GROUPcreationflags on Windows instead ofpreexec_fn=os.setsidEnvironment
I have a fix ready and can submit a PR.