I need help in understanding multiprocessing.Queue
. The problem I\'m facing is that getting results from queue.get(...)
are hilariously behind compared
For future readers, you could also try using:
q = multiprocessing.Manager().Queue()
Instead of just
q = multiprocessing.Queue()
I haven't yet fully distilled and understood the mechanisms behind this behavior, but one source I've read claimed it's about:
"when pushing large items onto the queue, the items are essentially buffered, despite the immediate return of the queue’s put function."
The author goes on explaining more about it and a way to fix, but for me, adding the Manager did the trick easy and clean.
UPDATE: I believe this StackOverflow answer is helpful in explaining the issue.
FMQ, mentioned in the accepted answer, is also Python2 exclusive, which is one of the reasons I felt this answer could maybe help more people someday.