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()
评论列表
文章目录