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,7 +579,7 @@ class NfoScanService:
|
||||
try:
|
||||
from src.server.nfo.tmdb_client import get_tmdb_client
|
||||
|
||||
client = get_tmdb_client()
|
||||
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]
|
||||
@@ -601,7 +601,7 @@ class NfoScanService:
|
||||
try:
|
||||
from src.server.nfo.tmdb_client import get_tmdb_client
|
||||
|
||||
client = get_tmdb_client()
|
||||
async with get_tmdb_client() as client:
|
||||
data = await client.get_tv_show_details(tmdb_id)
|
||||
return data
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user