Skip to content

Simplify the codebase and remove the psutil dependency - #40

Merged
CrypticSignal merged 4 commits into
mainfrom
ccr-0ad87562-vx7g4x
Nov 8, 2026
Merged

CrypticSignal merged 4 commits into
mainfrom
ccr-0ad87562-vx7g4x

Conversation

@CrypticSignal

@CrypticSignal CrypticSignal commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

Simplifies the package from about 1,120 to 775 lines without changing the public API, and bumps the version to 6.0.1.

  • Termination (terminate_process.py, 244 → 44 lines): FFmpeg already runs in its own process group, so the psutil-based child walking and fallbacks are replaced by signalling that group (SIGTERM, then SIGKILL after 2 seconds) on Linux/macOS, and terminate() on Windows. psutil is removed as a dependency.
  • Progress bars (progress_bars.py, 192 → 98 lines): the Rich and tqdm functions shared near-identical parsing loops. A single read_progress() generator in utils.py now reads FFmpeg's output, replacing the two old line parsers.
  • FfmpegProcess: run() now handles the unknown-duration case and the failure check once for both bars. __init__ is split into small helpers for log level, duration_override and default log-file name.
  • ruff.toml reduced from 73 to 7 lines (only non-default settings).
  • Version bumped to 6.0.1 and CHANGELOG.md updated.

CI fixes

ubuntu-latest is now Ubuntu 26.04, which broke CI independently of the changes above:

  • The test job now runs on ubuntu-24.04, because Ubuntu 26.04 has no Python 3.9 build for actions/setup-python.
  • test_failure_includes_log_tail now checks that the log tail is included rather than FFmpeg's exact wording. Newer FFmpeg versions say Encoder not found without naming the encoder.

Behaviour differences

  • When the duration can't be detected, ✓ Processed '<file>' is now printed with Rich too, not only tqdm.
  • Rich's description now quotes the filename, like tqdm's.
  • Stopping FFmpeg no longer logs diagnostics through the logging module.

Test plan

  • ruff check and ruff format --check pass
  • pytest: 48 tests pass with psutil uninstalled, including the Ctrl+C test
  • CI passes on Python 3.9–3.13
  • Ran test.py with Rich, a tqdm run, and a run with no detectable duration
  • Checked that a process ignoring SIGTERM is force-killed after 2 seconds
  • Windows termination path is untested (only Linux available)

🤖 Generated with Claude Code

https://claude.ai/code/session_01XaLfZ2px1aY8V13hGcztsq

- Replace the psutil-based termination logic with a short function that
  signals FFmpeg's process group (SIGTERM, then SIGKILL) on Unix and calls
  terminate() on Windows.
- Share the parsing of FFmpeg's progress output between the Rich and tqdm
  progress bars with a read_progress() generator, and move the handling of
  unknown durations and failures into FfmpegProcess.run().
- Split FfmpegProcess.__init__ into small helper functions.
- Reduce ruff.toml to the settings that differ from Ruff's defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaLfZ2px1aY8V13hGcztsq
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaLfZ2px1aY8V13hGcztsq
- Run the test job on ubuntu-24.04: ubuntu-latest is now Ubuntu 26.04,
  which has no Python 3.9 build for actions/setup-python.
- test_failure_includes_log_tail no longer depends on FFmpeg's error
  wording, which in newer versions does not name the missing encoder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaLfZ2px1aY8V13hGcztsq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XaLfZ2px1aY8V13hGcztsq
@CrypticSignal
CrypticSignal merged commit 5a5d5bd into main Nov 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants