def __init__(self, cmd, port):
try:
import zmq
except ImportError:
raise ImportError("Must have zeromq for remote learner.")
self.port = port if port is not None else 5556
self.context = zmq.Context()
self.socket = self.context.socket(zmq.PAIR)
self.socket.bind("tcp://*:%s" % port)
# launch learner
subprocess.Popen((cmd + ' ' + str(self.port)).split())
handshake_in = self.socket.recv()
assert handshake_in == 'hello' # handshake
# send to learner, and get response;
评论列表
文章目录