From 43f9c078389527327cb3338d2861c83c541fdfd7 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 11 Apr 2024 19:06:02 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/ws.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/ops/ws.py b/apps/ops/ws.py index 285503f6a..9605835a0 100644 --- a/apps/ops/ws.py +++ b/apps/ops/ws.py @@ -64,9 +64,16 @@ class TaskLogWebsocket(AsyncJsonWebsocketConsumer): async def async_handle_task(self, task_id, log_path): logger.info("Task id: {}".format(task_id)) + timeout = 0 while not self.disconnected: + if timeout >= 60: + await self.send_json({'message': '\r\n', 'task': task_id}) + await self.send_json({'message': 'Task log was not found, the directory may not be shared.', + 'task': task_id}) + break if not os.path.exists(log_path): await self.send_json({'message': '.', 'task': task_id}) + timeout += 0.5 await asyncio.sleep(0.5) else: await self.send_task_log(task_id, log_path)