Skip to content

Commit 1752121

Browse files
committed
Don't reconnect in the receive task
1 parent fb85fc2 commit 1752121

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

template/server/messaging.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,17 @@ async def _receive_message(self):
393393
await self._process_message(json.loads(message))
394394
except Exception as e:
395395
logger.error(f"WebSocket received error while receiving messages: {str(e)}")
396-
await self.reconnect()
396+
finally:
397+
# To prevent infinite hang, we need to cancel all ongoing execution as we could lost results during the reconnect
398+
for key, execution in self._executions.items():
399+
await execution.queue.put(
400+
Error(
401+
name="WebSocketError",
402+
value="The connections was lost, rerun the code to get the results",
403+
traceback="",
404+
)
405+
)
406+
await execution.queue.put(UnexpectedEndOfExecution())
397407

398408
async def _process_message(self, data: dict):
399409
"""

0 commit comments

Comments
 (0)