[zeromq-dev] differentiate send() ZMQError cases
Doug Meyer
dmeyer at gigaio.com
Wed Jul 31 20:55:27 CEST 2019
Dear zmq community,
I'm just getting my feet down on libzmq/pyzmq over here. I've read most of
the zguide and at least some of the pyzmq and libzmq API information. We're
python focused over here, and I'm running the following versions for my
proto work:
python 3.7.1
libzmq 4.3.1
pyzmq 18.0.1
I've been writing some very basic prototype code with a ROUTER-DEALER
pattern.
- The Master creates a ROUTER socket and binds to a TCP port.
- The Slaves create a DEALER and connect to the TCP port.
The code works fine at a basic level. And my basic discovery and protocol
stuff is good enough for the proof of concept that I'm building. ZMQ's very
straight-forward at this basic level, and I'm appreciative of the docs and
examples. Thanks to the ZMQ team!
Where I'm getting stuck is related to being able to identify and handle
some exceptional cases when sending. My questions surround
blocking/nonblocking send in conjunction with the zmq.ROUTER_MANDATORY
socket option and the zero (0) and zmq.NOBLOCK send() flag.
My understanding (and experience) is that if zmq.ROUTER_MANDATORY is NOT
set, then sends which cannot be sent either because the Identity has not
registered with the router, or the HWM has been reached, will be silently
dropped. I see that, and there's no issue there.
There is discussion in the zmq library docs of the ability to block on the
send. However, I have not found any way to block on send with pyzmq. If I
set zmq.ROUTER_MANDATORY and issue the send() or send_multipart() without
flags, I get zmq.error.ZMQError. Is there a way to make the send block? Is
there any effective difference between flags=0 and flags=zmq.NOBLOCK,
because I can't detect a difference behaviorally, though those two flags
are listed separately in the pyzmq API info for send().
Probably most critical for me, is there any way to differentiate between
these send() failures:
1. HWM mark reached
2. Identity is unknown (the slave with that Identity is not connected)
3. All other errors than (1) and (2)
I can imagine wanting to handle and report case (1) differently than (2),
as my decision tree and diagnostics are quite different and point to
distinct failure modes. Does pyzmq support any way to differentiate these?
Thank you so much for your time.
Blessings,
Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20190731/10165bd2/attachment.htm>
More information about the zeromq-dev
mailing list