I am trying to use python
with zeroMQ
in PUSH / PULL
mode, sending messages of size 4[MB] every few seconds.
For
The problem is that when the program exits, the socket gets closed immediately and garbage collected with an effective LINGER of 0 (i.e. it throws any unsent messages away). This is a problem for larger messages because they take longer to send than it takes for the socket to be garbage collected.
You can avoid this by putting a sleep(0.1)
just before the program exits (to delay the socket and context being garbage collected).
socket.setsockopt(zmq.LINGER, -1)
(which is the default) should avoid this problem, but it doesn't for some reason that I haven't had time to investigate.