[zeromq-dev] python3 2 threads and PAIR sockets, when to close?

MM finjulhich at gmail.com
Thu Sep 3 16:58:06 CEST 2015


I have:

def thread1():
  s = context.socket(zmq.PAIR)
  s.send_pyobj( dictionary )
  ### That's all I need to do , can I close s here?
  while True:
       # stay alive forever

def thread2():
   s = context.socket(zmq.PAIR)
   dx = s.recv_pyobj()
   while True:
       # stay alive forever

def main():
   time.sleep(5) #5secs
  #wait for signals

thread1 is the parent one, proceeds independently.
thread2 can only proceed once it got the dictionary from thread1

1. do I need the sleep(5) in the main thread to ensure thread1 bind happens
before thread2 connect?
2. can I close s in thread1 as soon as I send the dictionary?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150903/76395e00/attachment.htm>

More information about the zeromq-dev mailing list