mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-19 00:03:36 +00:00
Pause caption jobs during routing and between captions
This commit is contained in:
@@ -88,16 +88,19 @@ class CaptionJobManager:
|
||||
self._state["pause_requested"] = False
|
||||
self._state["paused"] = False
|
||||
if self._state.get("stage") == "paused":
|
||||
self._state["stage"] = "captioning"
|
||||
self._state["stage"] = str(
|
||||
self._state.get("paused_from_stage") or "captioning"
|
||||
)
|
||||
return self.status()
|
||||
|
||||
def _wait_if_paused(self) -> None:
|
||||
def _wait_if_paused(self, resume_stage: str = "captioning") -> None:
|
||||
if not self._pause_requested.is_set():
|
||||
return
|
||||
|
||||
with self._state_lock:
|
||||
self._state["paused"] = True
|
||||
self._state["pause_requested"] = True
|
||||
self._state["paused_from_stage"] = resume_stage
|
||||
self._state["stage"] = "paused"
|
||||
|
||||
while self._pause_requested.is_set():
|
||||
@@ -107,7 +110,7 @@ class CaptionJobManager:
|
||||
self._state["paused"] = False
|
||||
self._state["pause_requested"] = False
|
||||
if self._state.get("running"):
|
||||
self._state["stage"] = "captioning"
|
||||
self._state["stage"] = resume_stage
|
||||
|
||||
def start(self, library_ids: list[str], *, force: bool = False) -> dict[str, Any]:
|
||||
library_ids = [str(value).strip() for value in library_ids if str(value).strip()]
|
||||
@@ -219,6 +222,7 @@ class CaptionJobManager:
|
||||
rows,
|
||||
progress=self._progress,
|
||||
frame_source=frame_source,
|
||||
before_batch=lambda: self._wait_if_paused("routing"),
|
||||
)
|
||||
finally:
|
||||
self._set_gpu_busy(False)
|
||||
@@ -293,7 +297,7 @@ class CaptionJobManager:
|
||||
progress=general_progress,
|
||||
total_frames=frames_total,
|
||||
frame_source=frame_source,
|
||||
before_frame=self._wait_if_paused,
|
||||
before_frame=lambda: self._wait_if_paused("captioning"),
|
||||
)
|
||||
|
||||
if specialist_rows:
|
||||
@@ -317,13 +321,13 @@ class CaptionJobManager:
|
||||
completed_offset=general_done,
|
||||
total_frames=frames_total,
|
||||
frame_source=frame_source,
|
||||
before_frame=self._wait_if_paused,
|
||||
before_frame=lambda: self._wait_if_paused("captioning"),
|
||||
)
|
||||
|
||||
completed = general_done + specialist_done
|
||||
failed = missing + general_failed + specialist_failed
|
||||
|
||||
self._wait_if_paused()
|
||||
self._wait_if_paused("captioning")
|
||||
|
||||
self._progress(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user