4

I'm converting a source code written in Python 2 to Python 3 and I stumbled into 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 do I fix this?

Dimitris Fasarakis Hilliard
  • 150,925
  • 31
  • 268
  • 253
Moaz Ashraf
  • 210
  • 1
  • 3
  • 11

1 Answers1

8

multiprocessing.Queue is used for processes, don't let the capitalization confuse you. Queue, which was renamed to queue in Python 3, is for threads.

Both Empty and Queue are located in the queue module, so grab them from there.

Dimitris Fasarakis Hilliard
  • 150,925
  • 31
  • 268
  • 253