connector.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:catalearn 作者: Catalearn 项目源码 文件源码
def stream_output(gpu_ip, ws_port, job_hash):
    # connect to the websocket for this job
    url = 'ws://%s:%s' % (gpu_ip, ws_port)
    ws = create_connection(url)
    # send over the job hash to start the job
    ws.send(job_hash)
    # print all the outputs of the script to the screen
    # try:
    while True:
        msg = ws.recv()
        msgJson = json.loads(msg)
        if 'end' in msgJson:
            break
        else:
            print(msgJson['message'], end='')
    ws.close()
    return msgJson['hasResult']

    # if the user interrupts the job, decide whether or not to stop
    # except KeyboardInterrupt:
    #     # propagate the exception for the layer above to handle
    #     raise JobInterruptedException()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号