Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert oembed image endpoint to async #3457

Closed
sarayourfriend opened this issue Dec 5, 2023 · 0 comments · Fixed by #3458
Closed

Convert oembed image endpoint to async #3457

sarayourfriend opened this issue Dec 5, 2023 · 0 comments · Fixed by #3458
Assignees
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

Comments

@sarayourfriend
Copy link
Collaborator

Problem

The oembed image endpoint sometimes makes an outbound GET request to retrieve image dimensions.

image_file = requests.get(image.url, headers=self.OEMBED_HEADERS)

This can be converted to async to avoid blocking the worker on this outbound request.

Description

  1. Update the oembed endpoint to async def.
  2. Wrap get_object_or_404 in sync_to_async (it calls the synchronous Django ORM methods)
  3. Swap requests.get with aiohttp.get (retrieve aiohttp session using get_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.

@sarayourfriend sarayourfriend added help wanted Open to participation from the community 🟨 priority: medium Not blocking but should be addressed soon ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository 🐍 tech: python Involves Python 🔧 tech: django Involves Django 🧱 stack: api Related to the Django API labels Dec 5, 2023
@openverse-bot openverse-bot moved this to 📋 Backlog in Openverse Backlog Dec 5, 2023
@sarayourfriend sarayourfriend self-assigned this Dec 5, 2023
@sarayourfriend sarayourfriend moved this from 📋 Backlog to 🏗 In Progress in Openverse Backlog Dec 5, 2023
@openverse-bot openverse-bot moved this from 🏗 In Progress to ✅ Done in Openverse Backlog Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant