Fixed VideoProcessor cleanup race by skipping process kill when the subprocess has already exited.
CI / Formatting (push) Successful in 6s
CI / Linting (push) Successful in 5s
CI / Tests (Python 3.12) (push) Successful in 14s
CI / Tests (Python 3.13) (push) Successful in 13s
CI / Tests (Python 3.14) (push) Successful in 11s
CI / Type Checking (push) Successful in 8s
CI / Spelling (push) Successful in 5s
Audit / Dependencies (push) Successful in 8s

This commit is contained in:
2026-04-19 19:45:55 -04:00
parent e63827621e
commit bd5383b6ae
+9 -4
View File
@@ -20,6 +20,7 @@ Serializes ffmpeg/ffprobe execution via semaphores.
from __future__ import annotations
import asyncio
import contextlib
from typing import TYPE_CHECKING
import orjson
@@ -189,13 +190,17 @@ class VideoProcessor:
proc.communicate(), timeout=time_limit
)
except TimeoutError:
proc.kill()
await proc.wait()
if proc.returncode is None:
with contextlib.suppress(ProcessLookupError):
proc.kill()
await proc.wait()
msg = f"{args[0]} timed out after {time_limit}s"
raise RuntimeError(msg) from None
except asyncio.CancelledError:
proc.kill()
await proc.wait()
if proc.returncode is None:
with contextlib.suppress(ProcessLookupError):
proc.kill()
await proc.wait()
raise
if proc.returncode != 0: