fixes: web interface shutdown
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-20 08:30:55 -04:00
parent eb9bfbf82e
commit 3c4e47b08e
5 changed files with 91 additions and 9 deletions
+24
View File
@@ -631,6 +631,12 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
import re
tv_count = 0
for item in scan_path.iterdir():
# Check for shutdown signal at start of each item
shutdown_event = dependencies.get("shutdown_event")
if shutdown_event and shutdown_event.is_set():
print("INFO: ⚠️ SHUTDOWN SIGNAL RECEIVED - Stopping scan gracefully")
return
if (item.is_dir() and
not item.name.lower().startswith('season') and
not re.match(r'^season\s+\d+$', item.name, re.IGNORECASE) and
@@ -653,11 +659,23 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
if tv_count % 1 == 0:
await asyncio.sleep(0.2) # 200ms yield to process other requests
print(f"INFO: Processed {tv_count} TV series, yielding to other requests...")
# Check for shutdown signal
shutdown_event = dependencies.get("shutdown_event")
if shutdown_event and shutdown_event.is_set():
print("INFO: ⚠️ SHUTDOWN SIGNAL RECEIVED - Stopping scan gracefully")
return
if scan_type in ["both", "movies"] and scan_path in config.movie_paths:
print(f"INFO: Scanning movies in: {scan_path}")
movie_count = 0
for item in scan_path.iterdir():
# Check for shutdown signal at start of each movie
shutdown_event = dependencies.get("shutdown_event")
if shutdown_event and shutdown_event.is_set():
print("INFO: ⚠️ SHUTDOWN SIGNAL RECEIVED - Stopping scan gracefully")
return
if item.is_dir() and nfo_manager.find_movie_imdb_id(item):
movie_count += 1
print(f"INFO: Processing movie: {item.name}")
@@ -678,6 +696,12 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
if movie_count % 2 == 0:
await asyncio.sleep(0.2) # 200ms yield to process other requests
print(f"INFO: Processed {movie_count} movies, yielding to other requests...")
# Check for shutdown signal
shutdown_event = dependencies.get("shutdown_event")
if shutdown_event and shutdown_event.is_set():
print("INFO: ⚠️ SHUTDOWN SIGNAL RECEIVED - Stopping scan gracefully")
return
print(f"INFO: Completed movie scan: {movie_count} movies processed in {scan_path}")