From 3adf77617b365172ab0860238e3635ce0afb45e4 Mon Sep 17 00:00:00 2001 From: bennykok Date: Wed, 7 Feb 2024 19:55:05 +0800 Subject: [PATCH] fix(plugin): async file upload to make sure it is not blocking --- custom_routes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_routes.py b/custom_routes.py index 6169626..873180f 100644 --- a/custom_routes.py +++ b/custom_routes.py @@ -513,7 +513,9 @@ async def upload_file(prompt_id, filename, subfolder=None, content_type="image/p "Content-Length": str(len(data)), } response = requests.put(ok.get("url"), headers=headers, data=data) - print("upload file response", response.status_code) + async with aiohttp.ClientSession() as session: + async with session.put(ok.get("url"), headers=headers, data=data) as response: + print("upload file response", response.status) def have_pending_upload(prompt_id): if 'prompt_id' in prompt_metadata and 'uploading_nodes' in prompt_metadata[prompt_id] and len(prompt_metadata[prompt_id]['uploading_nodes']) > 0: