You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
650 B
Python
24 lines
650 B
Python
10 years ago
|
import zmq
|
||
|
|
||
|
class OfficeManager:
|
||
|
|
||
|
def __init__(self):
|
||
|
self.ctx = zmq.Context(1)
|
||
|
self.frontend = self.ctx.socket(zmq.SUB)
|
||
|
self.frontend.bind("tcp://*:10100")
|
||
|
self.frontend.setsockopt(zmq.SUBSCRIBE, b"")
|
||
|
|
||
|
self.backend = self.ctx.socket(zmq.PUB)
|
||
|
self.backend.bind("tcp://*:10101")
|
||
|
|
||
|
def run(self):
|
||
|
try:
|
||
|
zmq.device(zmq.FORWARDER, self.frontend, self.backend)
|
||
|
except Exception as e:
|
||
|
print(e)
|
||
|
print("Bringing down OfficeManager ZMQ...")
|
||
|
finally:
|
||
|
self.frontend.close()
|
||
|
self.backend.close()
|
||
|
self.ctx.term()
|