[object Object]

← back to Exo

shield process_prompt so downloads dont get cancelled when chatgpt api request times out

aa20562614201eca77ee292ca75be1e0e7edc192 · 2024-10-07 20:32:43 +0400 · Alex Cheema

Files touched

Diff

commit aa20562614201eca77ee292ca75be1e0e7edc192
Author: Alex Cheema <alexcheema123@gmail.com>
Date:   Mon Oct 7 20:32:43 2024 +0400

    shield process_prompt so downloads dont get cancelled when chatgpt api request times out
---
 exo/api/chatgpt_api.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/exo/api/chatgpt_api.py b/exo/api/chatgpt_api.py
index fae8c813..f88ce2d0 100644
--- a/exo/api/chatgpt_api.py
+++ b/exo/api/chatgpt_api.py
@@ -270,7 +270,10 @@ class ChatGPTAPI:
     if DEBUG >= 2: print(f"Sending prompt from ChatGPT api {request_id=} {shard=} {prompt=} {image_str=}")
 
     try:
-      await asyncio.wait_for(self.node.process_prompt(shard, prompt, image_str, request_id=request_id), timeout=self.response_timeout)
+      await asyncio.wait_for(
+        asyncio.shield(asyncio.create_task(self.node.process_prompt(shard, prompt, image_str, request_id=request_id))),
+        timeout=self.response_timeout
+      )
 
       if DEBUG >= 2: print(f"Waiting for response to finish. timeout={self.response_timeout}s")
 

← e8a87023 replace tailscale.devices with good old http, removing the n  ·  back to Exo  ·  fix the race condition in cleanup peers and run the peer che e80ee607 →