Fix async context manager usage in BackgroundLoaderService
- Changed 'async for' to 'async with' for get_db_session() - get_db_session() is @asynccontextmanager, requires async with not async for - Created 5 comprehensive unit tests verifying the fix - All tests pass, background loading now works correctly
This commit is contained in:
@@ -279,7 +279,7 @@ class BackgroundLoaderService:
|
||||
from src.server.database.connection import get_db_session
|
||||
from src.server.database.service import AnimeSeriesService
|
||||
|
||||
async for db in get_db_session():
|
||||
async with get_db_session() as db:
|
||||
try:
|
||||
# Check what data is missing
|
||||
missing = await self.check_missing_data(
|
||||
@@ -337,8 +337,6 @@ class BackgroundLoaderService:
|
||||
# Broadcast error
|
||||
await self._broadcast_status(task)
|
||||
|
||||
break # Exit async for loop after first iteration
|
||||
|
||||
finally:
|
||||
# Remove from active tasks
|
||||
self.active_tasks.pop(task.key, None)
|
||||
|
||||
Reference in New Issue
Block a user