web: fix for unresponsive web interface
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-15 10:13:25 -04:00
parent 909df0cc83
commit 79a311f8ec
5 changed files with 18 additions and 15 deletions
+1 -1
View File
@@ -1 +1 @@
2.2.4 2.2.6
+6 -6
View File
@@ -597,9 +597,9 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
except Exception as e: except Exception as e:
print(f"ERROR: Failed processing TV series {item}: {e}") print(f"ERROR: Failed processing TV series {item}: {e}")
# Yield control every 5 TV series to allow other requests # Yield control every 3 TV series to allow other requests
if tv_count % 5 == 0: if tv_count % 3 == 0:
await asyncio.sleep(0.1) # 100ms yield to process other requests await asyncio.sleep(0.01) # 10ms yield to process other requests
print(f"INFO: Processed {tv_count} TV series, yielding to other requests...") print(f"INFO: Processed {tv_count} TV series, yielding to other requests...")
if scan_type in ["both", "movies"] and scan_path in config.movie_paths: if scan_type in ["both", "movies"] and scan_path in config.movie_paths:
@@ -614,9 +614,9 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
except Exception as e: except Exception as e:
print(f"ERROR: Failed processing movie {item}: {e}") print(f"ERROR: Failed processing movie {item}: {e}")
# Yield control every 10 movies to allow other requests (webhooks, web interface) # Yield control every 5 movies to allow other requests (webhooks, web interface)
if movie_count % 10 == 0: if movie_count % 5 == 0:
await asyncio.sleep(0.1) # 100ms yield to process other requests await asyncio.sleep(0.01) # 10ms yield to process other requests
print(f"INFO: Processed {movie_count} movies, yielding to other requests...") print(f"INFO: Processed {movie_count} movies, yielding to other requests...")
print(f"INFO: Completed movie scan: {movie_count} movies processed in {scan_path}") print(f"INFO: Completed movie scan: {movie_count} movies processed in {scan_path}")
+2 -3
View File
@@ -104,7 +104,6 @@ async def get_tv_series_list(dependencies: dict,
where_conditions = [] where_conditions = []
params = [] params = []
having_conditions = [] having_conditions = []
having_params = []
if search: if search:
where_conditions.append("(s.imdb_id LIKE ? OR s.path LIKE ?)") where_conditions.append("(s.imdb_id LIKE ? OR s.path LIKE ?)")
@@ -146,7 +145,7 @@ async def get_tv_series_list(dependencies: dict,
HAVING {having_clause} HAVING {having_clause}
) filtered_series ) filtered_series
""" """
cursor.execute(count_query, params + having_params) cursor.execute(count_query, params)
else: else:
# Simple count when no HAVING clause # Simple count when no HAVING clause
count_query = f"SELECT COUNT(*) FROM series s WHERE {where_clause}" count_query = f"SELECT COUNT(*) FROM series s WHERE {where_clause}"
@@ -170,7 +169,7 @@ async def get_tv_series_list(dependencies: dict,
ORDER BY s.last_updated DESC ORDER BY s.last_updated DESC
LIMIT ? OFFSET ? LIMIT ? OFFSET ?
""" """
cursor.execute(query, params + having_params + [limit, skip]) cursor.execute(query, params + [limit, skip])
series = [] series = []
for row in cursor.fetchall(): for row in cursor.fetchall():
+4
View File
@@ -282,6 +282,10 @@ class MovieProcessor:
_log("DEBUG", f"Movie processing reached file mtime section: fix_dir_mtimes={config.fix_dir_mtimes}, dateadded={dateadded}") _log("DEBUG", f"Movie processing reached file mtime section: fix_dir_mtimes={config.fix_dir_mtimes}, dateadded={dateadded}")
# Yield control briefly during movie processing to allow web interface requests
import time
time.sleep(0.005) # 5ms yield per movie to improve responsiveness
# Save to database # Save to database
_log("DEBUG", f"About to save to database: imdb_id={imdb_id}, dateadded={dateadded}") _log("DEBUG", f"About to save to database: imdb_id={imdb_id}, dateadded={dateadded}")
try: try:
+5 -5
View File
@@ -97,9 +97,9 @@ class TVProcessor:
# Yield control every 10 episodes to allow other requests (webhooks, web interface) # Yield control every 10 episodes to allow other requests (webhooks, web interface)
if episode_count % 10 == 0: if episode_count % 10 == 0:
# Note: Since this is sync method, we can't use asyncio.sleep() import time
# This will require making process_series async or adding yield points in caller time.sleep(0.005) # 5ms yield to improve responsiveness during episode processing
pass _log("DEBUG", f"Processed {episode_count} episodes, yielding to allow other requests...")
# Skip season.nfo and tvshow.nfo creation - focus only on episode NFOs # Skip season.nfo and tvshow.nfo creation - focus only on episode NFOs
pass pass
@@ -258,7 +258,7 @@ class TVProcessor:
if filter_set and (season, episode_num) not in filter_set: if filter_set and (season, episode_num) not in filter_set:
continue continue
if season > 0 and episode_num > 0: if season >= 0 and episode_num > 0:
episodes_processed += 1 episodes_processed += 1
# Get basic episode info # Get basic episode info
@@ -707,7 +707,7 @@ class TVProcessor:
season = episode.get('seasonNumber', 0) season = episode.get('seasonNumber', 0)
episode_num = episode.get('episodeNumber', 0) episode_num = episode.get('episodeNumber', 0)
if season > 0 and episode_num > 0: if season >= 0 and episode_num > 0:
episode_map[(season, episode_num)] = episode episode_map[(season, episode_num)] = episode
return { return {