How to convert 'from import queue to queue empty' from Python 2 to Python 3?

I am converting source code written in Python 2 to Python 3 and I came across this:

from Queue import Queue, Empty

I changed it to:

from multiprocessing import Queue, Empty

But this gives me an exception:

ImportError: cannot import name 'Empty'

How to fix it?

+1
source share
1 answer

multiprocessing.Queueused for processes, don't let uppercase confuse you. Queue, which was renamed to Queuein Python 3, for threads.

Both Emptyand Queueare located in the module Queue, so grab them from there.

+3
source

All Articles