fix: use async context manager for TMDBClient to prevent resource leak
The TMDBClient was being instantiated but never closed, causing 'Unclosed client session' errors in the logs. Fixed by using 'async with' context manager which properly calls close() on exit. Changes: - _lookup_tmdb_id_by_name: wrapped client in async with - _fetch_tmdb_data: wrapped client in async with
This commit is contained in:
@@ -579,8 +579,8 @@ class NfoScanService:
|
||||
try:
|
||||
from src.server.nfo.tmdb_client import get_tmdb_client
|
||||
|
||||
client = get_tmdb_client()
|
||||
results = await client.search_tv_show(name)
|
||||
async with get_tmdb_client() as client:
|
||||
results = await client.search_tv_show(name)
|
||||
if results and results.get("results"):
|
||||
first_result = results["results"][0]
|
||||
return first_result.get("id")
|
||||
@@ -601,8 +601,8 @@ class NfoScanService:
|
||||
try:
|
||||
from src.server.nfo.tmdb_client import get_tmdb_client
|
||||
|
||||
client = get_tmdb_client()
|
||||
data = await client.get_tv_show_details(tmdb_id)
|
||||
async with get_tmdb_client() as client:
|
||||
data = await client.get_tv_show_details(tmdb_id)
|
||||
return data
|
||||
except Exception as exc:
|
||||
logger.warning("TMDB fetch failed for TMDB ID %s: %s", tmdb_id, exc)
|
||||
|
||||
Reference in New Issue
Block a user