mirror of https://github.com/jumpserver/jumpserver
perf: 优化任务日志输出
parent
6052306c04
commit
43f9c07838
|
@ -64,9 +64,16 @@ class TaskLogWebsocket(AsyncJsonWebsocketConsumer):
|
||||||
|
|
||||||
async def async_handle_task(self, task_id, log_path):
|
async def async_handle_task(self, task_id, log_path):
|
||||||
logger.info("Task id: {}".format(task_id))
|
logger.info("Task id: {}".format(task_id))
|
||||||
|
timeout = 0
|
||||||
while not self.disconnected:
|
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):
|
if not os.path.exists(log_path):
|
||||||
await self.send_json({'message': '.', 'task': task_id})
|
await self.send_json({'message': '.', 'task': task_id})
|
||||||
|
timeout += 0.5
|
||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
else:
|
else:
|
||||||
await self.send_task_log(task_id, log_path)
|
await self.send_task_log(task_id, log_path)
|
||||||
|
|
Loading…
Reference in New Issue