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: # for each enabled buro in config # proc = subprocess.Popen([sys.executable, "mybuero.py"]) 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()