PUBHandler and listener should support connect and bind respectively
PUBHandler by default will bind a socket to the given address while the builtin listener will connect to the address. This is fine insofar as usually PUB is bound and SUB is connected but there is nothing that requires this pattern. In fact I would like to use PUBHandler as an easy way for distributed workers to send log messages to a central manager. With the default behavior if more than one worker uses the same address then I get errors regarding the address already being in use. I can work around this by creating the socket myself like:
ctx = zmq.Context.instance()
socket = ctx.socket(zmq.PUSH)
socket.connect("inproc://test")
logger = logging.getLogger("test")
logger.setLevel(logging.INFO)
handler = PUBHandler(socket)
handler.setLevel(logging.INFO)
logger.addHandler(handler)
but then I have to write the listener logic myself since there is no way to have it bind rather than connect. Ideally we could have options that allow us to select bind vs. connect, something like:
handler = PUBHandler("tcp://127.0.0.1:12345", connect=True)
and
python -m zmq.log --bind tcp://127.0.0.1:12345
If there is openness to allow for toggling this I'm willing to open a PR.