MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / __init__

Method __init__

examples/A3C-Gym/simulator.py:100–135  ·  view source on GitHub ↗

Args: pipe_c2s, pipe_s2c (str): names of pipe to be used for communication

(self, pipe_c2s, pipe_s2c)

Source from the content-addressed store, hash-verified

98 self.ident = None
99
100 def __init__(self, pipe_c2s, pipe_s2c):
101 """
102 Args:
103 pipe_c2s, pipe_s2c (str): names of pipe to be used for communication
104 """
105 super(SimulatorMaster, self).__init__()
106 assert os.name != 'nt', "Doesn't support windows!"
107 self.daemon = True
108 self.name = 'SimulatorMaster'
109
110 self.context = zmq.Context()
111
112 self.c2s_socket = self.context.socket(zmq.PULL)
113 self.c2s_socket.bind(pipe_c2s)
114 self.c2s_socket.set_hwm(10)
115 self.s2c_socket = self.context.socket(zmq.ROUTER)
116 self.s2c_socket.bind(pipe_s2c)
117 self.s2c_socket.set_hwm(10)
118
119 # queueing messages to client
120 self.send_queue = queue.Queue(maxsize=100)
121
122 def f():
123 msg = self.send_queue.get()
124 self.s2c_socket.send_multipart(msg, copy=False)
125 self.send_thread = LoopThread(f)
126 self.send_thread.daemon = True
127 self.send_thread.start()
128
129 # make sure socket get closed at the end
130 def clean_context(soks, context):
131 for s in soks:
132 s.close()
133 context.term()
134 import atexit
135 atexit.register(clean_context, [self.c2s_socket, self.s2c_socket], self.context)
136
137 def run(self):
138 self.clients = defaultdict(self.ClientState)

Callers 1

__init__Method · 0.45

Calls 3

LoopThreadClass · 0.90
registerMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected