Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Close old db connections after getting thumbnails (#5335)

Krystle Salazarf41f20d27615
diff --git a/api/api/utils/image_proxy/__init__.py b/api/api/utils/image_proxy/__init__.py
index 5f3be6906..d130bfd22 100644
--- a/api/api/utils/image_proxy/__init__.py
+++ b/api/api/utils/image_proxy/__init__.py
@@ -3,6 +3,7 @@ from typing import Literal
from urllib.parse import urlparse
from django.conf import settings
+from django.db import close_old_connections
from django.http import HttpResponse
from rest_framework.exceptions import UnsupportedMediaType
@@ -297,3 +298,5 @@ async def get(
)
raise UpstreamThumbnailException(f"Failed to render thumbnail. {exc}")
+ finally:
+ close_old_connections()