Skip to content

Commit 48fe7b9

Browse files
authored
Merge pull request #306 from exo-explore/process_prompt_shield
shield process_prompt so downloads dont get cancelled when chatgpt api request times out fixes #305
2 parents 7b2a523 + aa20562 commit 48fe7b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

exo/api/chatgpt_api.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ async def handle_post_chat_completions(self, request):
270270
if DEBUG >= 2: print(f"Sending prompt from ChatGPT api {request_id=} {shard=} {prompt=} {image_str=}")
271271

272272
try:
273-
await asyncio.wait_for(self.node.process_prompt(shard, prompt, image_str, request_id=request_id), timeout=self.response_timeout)
273+
await asyncio.wait_for(
274+
asyncio.shield(asyncio.create_task(self.node.process_prompt(shard, prompt, image_str, request_id=request_id))),
275+
timeout=self.response_timeout
276+
)
274277

275278
if DEBUG >= 2: print(f"Waiting for response to finish. timeout={self.response_timeout}s")
276279

0 commit comments

Comments
 (0)