Convert oembed image endpoint to async #3457
Labels
💻 aspect: code
Concerns the software code in the repository
✨ goal: improvement
Improvement to an existing user-facing feature
help wanted
Open to participation from the community
🟨 priority: medium
Not blocking but should be addressed soon
🧱 stack: api
Related to the Django API
🔧 tech: django
Involves Django
🐍 tech: python
Involves Python
Problem
The oembed image endpoint sometimes makes an outbound GET request to retrieve image dimensions.
openverse/api/api/views/image_views.py
Line 120 in b91cdc3
This can be converted to async to avoid blocking the worker on this outbound request.
Description
async def
.get_object_or_404
insync_to_async
(it calls the synchronous Django ORM methods)requests.get
withaiohttp.get
(retrieve aiohttp session usingget_aiohttp_session
)That should be it! All tests should continue to pass. There may need to be minor changes to accommodate the requests to aiohttp switch.
The text was updated successfully, but these errors were encountered: