python - Using process instead of thread with zeromq -


i'm reading code http://zguide.zeromq.org/py:mtserver when i've tried replace threading.thread multiprocessing.process got error

assertion failed: ok (mailbox.cpp:84)

code is

import time import threading import zmq  def worker_routine(worker_url, context=none):     """worker routine"""     context = context or zmq.context.instance()     # socket talk dispatcher     socket = context.socket(zmq.rep)      socket.connect(worker_url)      while true:          string  = socket.recv()          print("received request: [ %s ]" % (string))          # 'work'         time.sleep(1)          #send reply client         socket.send(b"world")  def main():     """server routine"""      url_worker = "inproc://workers"     url_client = "tcp://*:5555"      # prepare our context , sockets     context = zmq.context.instance()      # socket talk clients     clients = context.socket(zmq.router)     clients.bind(url_client)      # socket talk workers     workers = context.socket(zmq.dealer)     workers.bind(url_worker)      # launch pool of worker threads     in range(5):         process = multiprocessing.process(target=worker_routine, args=(url_worker,))         process.start()      zmq.device(zmq.queue, clients, workers)      # never here clean anyhow     clients.close()     workers.close()     context.term()  if __name__ == "__main__":     main() 

the limitations of each transport detailed in api.

inproc intra-process communication (i.e. threads). should try ipc support inter-process communication or tcp.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -