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
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:
@@ -20,6 +20,7 @@ Serializes ffmpeg/ffprobe execution via semaphores.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import contextlib
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import orjson
|
import orjson
|
||||||
@@ -189,13 +190,17 @@ class VideoProcessor:
|
|||||||
proc.communicate(), timeout=time_limit
|
proc.communicate(), timeout=time_limit
|
||||||
)
|
)
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
proc.kill()
|
if proc.returncode is None:
|
||||||
await proc.wait()
|
with contextlib.suppress(ProcessLookupError):
|
||||||
|
proc.kill()
|
||||||
|
await proc.wait()
|
||||||
msg = f"{args[0]} timed out after {time_limit}s"
|
msg = f"{args[0]} timed out after {time_limit}s"
|
||||||
raise RuntimeError(msg) from None
|
raise RuntimeError(msg) from None
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
proc.kill()
|
if proc.returncode is None:
|
||||||
await proc.wait()
|
with contextlib.suppress(ProcessLookupError):
|
||||||
|
proc.kill()
|
||||||
|
await proc.wait()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user