removed cancel request
This commit is contained in:
parent
803f35ef39
commit
ff9dea0488
@ -199,24 +199,6 @@ class SeriesApp:
|
|||||||
"""Set scan_status event handler."""
|
"""Set scan_status event handler."""
|
||||||
self._events.scan_status = value
|
self._events.scan_status = value
|
||||||
|
|
||||||
def request_download_cancel(self) -> None:
|
|
||||||
"""Request cancellation of any ongoing download.
|
|
||||||
|
|
||||||
This method signals the download provider to stop any active
|
|
||||||
downloads. The actual cancellation happens asynchronously in
|
|
||||||
the progress hook of the downloader.
|
|
||||||
"""
|
|
||||||
logger.info("Requesting download cancellation")
|
|
||||||
self.loader.request_cancel()
|
|
||||||
|
|
||||||
def reset_download_cancel(self) -> None:
|
|
||||||
"""Reset the download cancellation flag.
|
|
||||||
|
|
||||||
Should be called before starting a new download to ensure
|
|
||||||
it's not immediately cancelled.
|
|
||||||
"""
|
|
||||||
self.loader.reset_cancel()
|
|
||||||
|
|
||||||
def load_series_from_list(self, series: list) -> None:
|
def load_series_from_list(self, series: list) -> None:
|
||||||
"""
|
"""
|
||||||
Load series into the in-memory list.
|
Load series into the in-memory list.
|
||||||
@ -304,8 +286,6 @@ class SeriesApp:
|
|||||||
lookups. The 'serie_folder' parameter is only used for
|
lookups. The 'serie_folder' parameter is only used for
|
||||||
filesystem operations.
|
filesystem operations.
|
||||||
"""
|
"""
|
||||||
# Reset cancel flag before starting new download
|
|
||||||
self.reset_download_cancel()
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Starting download: %s (key: %s) S%02dE%02d",
|
"Starting download: %s (key: %s) S%02dE%02d",
|
||||||
|
|||||||
@ -205,30 +205,6 @@ class AniworldLoader(Loader):
|
|||||||
logging.debug(f"Available languages for S{season:02}E{episode:03}: {languages}, requested: {language_code}, available: {is_available}")
|
logging.debug(f"Available languages for S{season:02}E{episode:03}: {languages}, requested: {language_code}, available: {is_available}")
|
||||||
return is_available
|
return is_available
|
||||||
|
|
||||||
def request_cancel(self) -> None:
|
|
||||||
"""Request cancellation of any ongoing download.
|
|
||||||
|
|
||||||
Sets the internal cancellation flag. Downloads will check this
|
|
||||||
flag periodically and abort if set.
|
|
||||||
"""
|
|
||||||
logging.info("Download cancellation requested")
|
|
||||||
self._cancel_flag.set()
|
|
||||||
|
|
||||||
def reset_cancel(self) -> None:
|
|
||||||
"""Reset the cancellation flag.
|
|
||||||
|
|
||||||
Should be called before starting a new download.
|
|
||||||
"""
|
|
||||||
self._cancel_flag.clear()
|
|
||||||
|
|
||||||
def is_cancelled(self) -> bool:
|
|
||||||
"""Check if cancellation has been requested.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
bool: True if cancellation was requested
|
|
||||||
"""
|
|
||||||
return self._cancel_flag.is_set()
|
|
||||||
|
|
||||||
def download(
|
def download(
|
||||||
self,
|
self,
|
||||||
base_directory: str,
|
base_directory: str,
|
||||||
|
|||||||
@ -4,29 +4,17 @@ from typing import Any, Callable, Dict, List, Optional
|
|||||||
|
|
||||||
class Loader(ABC):
|
class Loader(ABC):
|
||||||
"""Abstract base class for anime data loaders/providers."""
|
"""Abstract base class for anime data loaders/providers."""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def request_cancel(self) -> None:
|
def subscribe_download_progress(self, handler):
|
||||||
"""Request cancellation of any ongoing download.
|
"""Subscribe a handler to the download_progress event.
|
||||||
|
Args:
|
||||||
Sets an internal flag that downloads should check periodically
|
handler: Callable to be called with progress dict.
|
||||||
and abort if set. This enables graceful shutdown.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def reset_cancel(self) -> None:
|
def unsubscribe_download_progress(self, handler):
|
||||||
"""Reset the cancellation flag.
|
"""Unsubscribe a handler from the download_progress event.
|
||||||
|
Args:
|
||||||
Should be called before starting a new download to ensure
|
handler: Callable previously subscribed.
|
||||||
it's not immediately cancelled.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def is_cancelled(self) -> bool:
|
|
||||||
"""Check if cancellation has been requested.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
bool: True if cancellation was requested
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|||||||
@ -191,10 +191,6 @@ async def lifespan(_application: FastAPI):
|
|||||||
)
|
)
|
||||||
if _download_service_instance is not None:
|
if _download_service_instance is not None:
|
||||||
logger.info("Stopping download service...")
|
logger.info("Stopping download service...")
|
||||||
await asyncio.wait_for(
|
|
||||||
_download_service_instance.stop(timeout=min(10.0, remaining_time())),
|
|
||||||
timeout=min(15.0, remaining_time())
|
|
||||||
)
|
|
||||||
logger.info("Download service stopped successfully")
|
logger.info("Download service stopped successfully")
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
logger.warning("Download service shutdown timed out")
|
logger.warning("Download service shutdown timed out")
|
||||||
@ -206,7 +202,6 @@ async def lifespan(_application: FastAPI):
|
|||||||
progress_service = get_progress_service()
|
progress_service = get_progress_service()
|
||||||
logger.info("Cleaning up progress service...")
|
logger.info("Cleaning up progress service...")
|
||||||
# Clear any active progress tracking and subscribers
|
# Clear any active progress tracking and subscribers
|
||||||
progress_service._subscribers.clear()
|
|
||||||
progress_service._active_progress.clear()
|
progress_service._active_progress.clear()
|
||||||
logger.info("Progress service cleanup complete")
|
logger.info("Progress service cleanup complete")
|
||||||
except Exception as e: # pylint: disable=broad-exception-caught
|
except Exception as e: # pylint: disable=broad-exception-caught
|
||||||
|
|||||||
@ -72,20 +72,6 @@ class AnimeService:
|
|||||||
logger.exception("Failed to subscribe to SeriesApp events")
|
logger.exception("Failed to subscribe to SeriesApp events")
|
||||||
raise AnimeServiceError("Initialization failed") from e
|
raise AnimeServiceError("Initialization failed") from e
|
||||||
|
|
||||||
def request_download_cancel(self) -> None:
|
|
||||||
"""Request cancellation of any ongoing download.
|
|
||||||
|
|
||||||
This method signals the underlying download provider to stop
|
|
||||||
any active downloads. The cancellation happens asynchronously
|
|
||||||
via progress hooks in the downloader.
|
|
||||||
|
|
||||||
Should be called during shutdown to stop in-progress downloads.
|
|
||||||
"""
|
|
||||||
logger.info("Requesting download cancellation via AnimeService")
|
|
||||||
try:
|
|
||||||
self._app.request_download_cancel()
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning("Failed to request download cancellation: %s", e)
|
|
||||||
|
|
||||||
def _on_download_status(self, args) -> None:
|
def _on_download_status(self, args) -> None:
|
||||||
"""Handle download status events from SeriesApp.
|
"""Handle download status events from SeriesApp.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user