##// END OF EJS Templates
specify heartbeat port at construction, not in run...
MinRK -
Show More
@@ -12,6 +12,7 b''
12 12 # Imports
13 13 #-----------------------------------------------------------------------------
14 14
15 import socket
15 16 import sys
16 17 from threading import Thread
17 18
@@ -33,13 +34,16 b' class Heartbeat(Thread):'
33 34 self.addr = addr
34 35 self.ip = addr[0]
35 36 self.port = addr[1]
37 if self.port == 0:
38 s = socket.socket()
39 s.bind(self.addr)
40 self.port = s.getsockname()[1]
41 s.close()
42 self.addr = (self.ip, self.port)
36 43 self.daemon = True
37 44
38 45 def run(self):
39 46 self.socket = self.context.socket(zmq.REP)
40 if self.port == 0:
41 self.port = self.socket.bind_to_random_port('tcp://%s' % self.ip)
42 else:
43 self.socket.bind('tcp://%s:%i' % self.addr)
47 self.socket.bind('tcp://%s:%i' % self.addr)
44 48 zmq.device(zmq.FORWARDER, self.socket, self.socket)
45 49
General Comments 0
You need to be logged in to leave comments. Login now