Termination of python script while using ZeroMQ with dead server
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Romantic Lands Beckon
--
Chapters
00:00 Termination Of Python Script While Using Zeromq With Dead Server
01:15 Accepted Answer Score 8
01:40 Thank you
--
Full question
https://stackoverflow.com/questions/1714...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #zeromq #termination #pyzmq
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Romantic Lands Beckon
--
Chapters
00:00 Termination Of Python Script While Using Zeromq With Dead Server
01:15 Accepted Answer Score 8
01:40 Thank you
--
Full question
https://stackoverflow.com/questions/1714...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #zeromq #termination #pyzmq
#avk47
ACCEPTED ANSWER
Score 8
You are encountering ZeroMQ's LINGER behaviour. LINGER defines how long the Context should wait before allowing Context.term to discard messages. The default in ZeroMQ 2.x is forever, and the default in ZeroMQ 3.x is one second. If you tell your sockets that they should only linger a short time, your script should exit just fine:
socket = context.socket(zmq.REQ)
socket_id = randomID()
socket.identity = ramdomID()
socket.linger = 250 # 250ms = 1/4 s
socket.connect("tcp://dead_server")