queue.py 498 B

12345678910111213141516171819202122
  1. import collections
  2. from ..packages import six
  3. from ..packages.six.moves import queue
  4. if six.PY2:
  5. # Queue is imported for side effects on MS Windows. See issue #229.
  6. import Queue as _unused_module_Queue # noqa: F401
  7. class LifoQueue(queue.Queue):
  8. def _init(self, _):
  9. self.queue = collections.deque()
  10. def _qsize(self, len=len):
  11. return len(self.queue)
  12. def _put(self, item):
  13. self.queue.append(item)
  14. def _get(self):
  15. return self.queue.pop()