python - Debug Multiple Processing Queue in multiple consolse -


i want interact multiprocessing queue data in multiple consoles following:

#test.py import multiprocessing global queue queue = multiprocessing.queue()  #python console 1 test import queue queue.put("this console 1")  #python console 2 test import queue print queue.get() #"this console 1" 

but doesn't work.what missing?

if understood correctly trying do, cannot work. i'm assuming "console" mean python interactive prompt.

  1. you start "console 1", os process. create queue object in it, , put on it.

  2. you start "console 2", os process not created through process object. create queue object in different object 1 created in "console 1". try nothing because nothing has been put on it. (the fact both import test.py irrelevant.)

queue object not meant serve communication channel processes not related means of process object. see instance, example documentation:

from multiprocessing import process, queue  def f(q):     q.put([42, none, 'hello'])  if __name__ == '__main__':     q = queue()     p = process(target=f, args=(q,))     p.start()     print q.get()    # prints "[42, none, 'hello']"     p.join() 

now how 2nd process created using process. p process being created through process shares same q queue original process.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -