Refa: convert download_img to async (#13477)

### What problem does this PR solve?

Convert download_img to async.

### Type of change

- [x] Refactoring
- [x] Performance Improvement
This commit is contained in:
Yongteng Lei
2026-03-09 19:00:17 +08:00
committed by GitHub
parent 52bcd98d29
commit 7484298c82
4 changed files with 14 additions and 10 deletions

View File

@ -27,16 +27,16 @@ import uuid
from concurrent.futures import ThreadPoolExecutor
import requests
def get_uuid():
return uuid.uuid1().hex
def download_img(url):
async def download_img(url):
if not url:
return ""
response = requests.get(url)
from common.http_client import async_request
response = await async_request("GET", url)
return "data:" + \
response.headers.get('Content-Type', 'image/jpg') + ";" + \
"base64," + base64.b64encode(response.content).decode("utf-8")