Skip to content

Windows crash: os.killpg not available (YouTube search fails) #156

@flobo3

Description

@flobo3

Bug

YouTube search crashes on Windows with:

AttributeError: module 'os' has no attribute 'killpg'

Steps to reproduce

  1. Run last30days.py on Windows (Python 3.12)
  2. YouTube source is enabled (yt-dlp installed)
  3. Any topic triggers the crash during search or transcript fetch

Root cause

Two issues in scripts/lib/youtube_yt.py:

  1. 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.

  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions