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.
|
|
|
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()
|