导航

 
from websocket import create_connection
    # 建立一个websocket连接
    ws = create_connection("ws://{}:7505/realtime/logs".format(server_ip))
    # 对websocket客户端发送一个请求
    print task_id
    ws.send('{{"type":"1","taskId":{},"source":"1"}}'.format(task_id))
    # 接收返回的数据

    while 1:
        result = ws.recv()
        print(str(result))
        if 'Task status: success' in str(result) and 'Current time:' in str(result):
            ws.close()
            success=True
            break
        elif 'Task status: ' in str(result) and 'Current time:' in str(result):
            ws.close()
            success = False
            break

  

posted on 2019-08-20 16:25  slqt  阅读(893)  评论(0编辑  收藏  举报