完成线程启动训练并以websocket的方式进行发送shell
This commit is contained in:
@ -44,17 +44,17 @@ my_app.include_router(web_socket, prefix="/ws", tags=["websocket管理"])
|
||||
|
||||
|
||||
# fastapi定时执行任务
|
||||
async def periodic_task():
|
||||
async def serve_info_task():
|
||||
while True:
|
||||
server_json = get_server_json()
|
||||
await room_manager.send_to_room('server-info', server_json)
|
||||
await asyncio.sleep(2) # 每 10 秒执行
|
||||
await asyncio.sleep(5) # 每 5 秒执行
|
||||
|
||||
|
||||
@my_app.on_event("startup")
|
||||
async def start_periodic_task():
|
||||
# 在后台启动异步任务
|
||||
asyncio.create_task(periodic_task())
|
||||
asyncio.create_task(serve_info_task())
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user