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.
you start "console 1", os process. create
queue
object in it, , put on it.you start "console 2", os process not created through
process
object. createqueue
object in different object 1 created in "console 1". try nothing because nothing has been put on it. (the fact both importtest.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
Post a Comment