python3: add polyglot.queue wrapper

This commit is contained in:
Eli Schwartz 2019-03-19 17:11:00 -04:00
parent ea6a210e70
commit 83b055122a
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
36 changed files with 62 additions and 54 deletions

View File

@ -8,11 +8,11 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
import os, tempfile, shutil, errno, time, atexit
from threading import Thread
from Queue import Queue
from calibre.ptempfile import remove_dir
from calibre.utils.filenames import remove_dir_if_empty
from calibre.utils.recycle_bin import delete_tree, delete_file
from polyglot.queue import Queue
class DeleteService(Thread):
@ -159,4 +159,3 @@ def has_jobs():
if __ds is not None:
return (not __ds.requests.empty()) or __ds.requests.unfinished_tasks
return False

View File

@ -11,7 +11,6 @@ import socket, select, json, os, traceback, time, sys, random
import posixpath
from collections import defaultdict
import hashlib, threading
import Queue
from functools import wraps
from errno import EAGAIN, EINTR
@ -39,6 +38,7 @@ from calibre.utils.mdns import (publish as publish_zeroconf, unpublish as
unpublish_zeroconf, get_all_ips)
from calibre.utils.socket_inheritance import set_socket_inherit
from polyglot.builtins import unicode_type
from polyglot import queue
def synchronous(tlockname):
@ -103,7 +103,7 @@ class ConnectionListener(Thread):
{'otherDevice': d.get_gui_name()})
self.driver._send_byte_string(device_socket, (b'%d' % len(s)) + s)
sock.close()
except Queue.Empty:
except queue.Empty:
pass
if getattr(self.driver, 'broadcast_socket', None) is not None:
@ -148,7 +148,7 @@ class ConnectionListener(Thread):
try:
self.driver.connection_queue.put_nowait(device_socket)
except Queue.Full:
except queue.Full:
self._close_socket(device_socket)
device_socket = None
self.driver._debug('driver is not answering')
@ -993,7 +993,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
raise
except:
pass
except Queue.Empty:
except queue.Empty:
self.is_connected = False
return self if self.is_connected else None
return None
@ -1969,7 +1969,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
message = 'attaching port to broadcast socket failed. This is not fatal.'
self._debug(message)
self.connection_queue = Queue.Queue(1)
self.connection_queue = queue.Queue(1)
self.connection_listener = ConnectionListener(self)
self.connection_listener.start()
return message

View File

@ -8,7 +8,6 @@ Based on ideas from comiclrf created by FangornUK.
'''
import os, traceback, time
from Queue import Empty
from calibre import extract, prints, walk
from calibre.constants import filesystem_encoding
@ -17,6 +16,7 @@ from calibre.utils.icu import numeric_sort_key
from calibre.utils.ipc.server import Server
from calibre.utils.ipc.job import ParallelJob
from polyglot.builtins import unicode_type
from polyglot.queue import Empty
# If the specified screen has either dimension larger than this value, no image
# rescaling is done (we assume that it is a tablet output profile)

View File

@ -8,7 +8,6 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os, tempfile, time
from Queue import Queue, Empty
from threading import Event
from calibre.customize.ui import all_metadata_plugins
@ -16,6 +15,7 @@ from calibre import prints, sanitize_file_name2
from calibre.ebooks.metadata import check_isbn
from calibre.ebooks.metadata.sources.base import create_log, get_cached_cover_urls
from calibre.ebooks.metadata.sources.prefs import msprefs
from polyglot.queue import Queue, Empty
def isbn_test(isbn):

View File

@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import os
from collections import Counter
from io import BytesIO
from Queue import Empty, Queue
from threading import Event, Thread
from calibre.customize.ui import metadata_plugins
@ -18,6 +17,7 @@ from calibre.ebooks.metadata.sources.identify import identify, msprefs
from calibre.ebooks.metadata.sources.update import patch_plugins
from calibre.utils.date import as_utc
from calibre.utils.logging import GUILog
from polyglot.queue import Empty, Queue
def merge_result(oldmi, newmi, ensure_fields=None):

View File

@ -9,7 +9,6 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
import os
from collections import defaultdict
from threading import Thread
from Queue import Queue, Empty
from calibre import browser
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES, urlunquote, XHTML_MIME
@ -21,6 +20,7 @@ from calibre.ebooks.oeb.polish.utils import guess_type, actual_case_for_name, co
from calibre.ebooks.oeb.polish.check.base import BaseError, WARN, INFO
from polyglot.builtins import map, range
from polyglot.urllib import urlparse
from polyglot.queue import Queue, Empty
class BadLink(BaseError):

View File

@ -7,10 +7,10 @@ from __future__ import (unicode_literals, division, absolute_import,
import os
from functools import partial
from threading import Thread, Event
from Queue import Queue, Empty
from calibre import detect_ncpus, human_readable, force_unicode, filesystem_encoding
from polyglot.builtins import range
from polyglot.queue import Queue, Empty
class Worker(Thread):

View File

@ -3,7 +3,6 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
""" The GUI """
import glob
import os
import Queue
import signal
import sys
import threading
@ -36,6 +35,7 @@ from calibre.utils.date import UNDEFINED_DATE
from calibre.utils.file_type_icons import EXT_MAP
from calibre.utils.localization import get_lang
from polyglot.builtins import unicode_type, string_or_bytes, range
from polyglot import queue
try:
NO_URL_FORMATTING = QUrl.None_
@ -502,7 +502,7 @@ class FunctionDispatcher(QObject):
if not queued:
typ = Qt.AutoConnection if queued is None else Qt.DirectConnection
self.dispatch_signal.connect(self.dispatch, type=typ)
self.q = Queue.Queue()
self.q = queue.Queue()
self.lock = threading.Lock()
def __call__(self, *args, **kwargs):

View File

@ -9,7 +9,6 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
import shutil, os, weakref, traceback, tempfile, time
from threading import Thread
from collections import OrderedDict
from Queue import Empty
from io import BytesIO
from polyglot.builtins import map, unicode_type, string_or_bytes
@ -30,6 +29,7 @@ from calibre.ptempfile import PersistentTemporaryDirectory
from calibre.utils import join_with_timeout
from calibre.utils.config import prefs
from calibre.utils.ipc.pool import Pool, Failure
from polyglot.queue import Empty
def validate_source(source, parent=None): # {{{

View File

@ -3,7 +3,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
# Imports {{{
import os, traceback, Queue, time, io, re, sys, weakref
import os, traceback, time, io, re, sys, weakref
from threading import Thread, Event
from PyQt5.Qt import (
@ -35,6 +35,7 @@ from calibre.utils.img import scale_image
from calibre.library.save_to_disk import find_plugboard
from calibre.ptempfile import PersistentTemporaryFile, force_unicode as filename_to_unicode
from polyglot.builtins import unicode_type, string_or_bytes
from polyglot import queue
# }}}
@ -153,8 +154,8 @@ class DeviceManager(Thread): # {{{
self.sleep_time = sleep_time
self.connected_slot = connected_slot
self.allow_connect_slot = allow_connect_slot
self.jobs = Queue.Queue(0)
self.job_steps = Queue.Queue(0)
self.jobs = queue.Queue(0)
self.job_steps = queue.Queue(0)
self.keep_going = True
self.job_manager = job_manager
self.reported_errors = set([])
@ -163,7 +164,7 @@ class DeviceManager(Thread): # {{{
self.connected_device = None
self.connected_device_kind = None
self.ejected_devices = set([])
self.mount_connection_requests = Queue.Queue(0)
self.mount_connection_requests = queue.Queue(0)
self.open_feedback_slot = open_feedback_slot
self.open_feedback_only_once_seen = set()
self.after_callback_feedback_slot = after_callback_feedback_slot
@ -241,7 +242,7 @@ class DeviceManager(Thread): # {{{
try:
job = self.jobs.get_nowait()
job.abort(Exception(_('Device no longer connected.')))
except Queue.Empty:
except queue.Empty:
break
try:
self.connected_device.post_yank_cleanup()
@ -358,13 +359,13 @@ class DeviceManager(Thread): # {{{
if not self.job_steps.empty():
try:
return self.job_steps.get_nowait()
except Queue.Empty:
except queue.Empty:
pass
if not self.jobs.empty():
try:
return self.jobs.get_nowait()
except Queue.Empty:
except queue.Empty:
pass
def run_startup(self, dev):
@ -391,7 +392,7 @@ class DeviceManager(Thread): # {{{
try:
(kls,device_kind, folder_path) = \
self.mount_connection_requests.get_nowait()
except Queue.Empty:
except queue.Empty:
break
if kls is not None:
try:

View File

@ -9,7 +9,6 @@ __docformat__ = 'restructuredtext en'
import posixpath, os, re
from threading import Thread
from Queue import Queue, Empty
from PyQt5.Qt import QPixmap, Qt, QDialog, QLabel, QVBoxLayout, \
QDialogButtonBox, QProgressBar, QTimer, QUrl, QImageReader
@ -21,6 +20,7 @@ from calibre.gui2 import error_dialog
from calibre.utils.imghdr import what
from polyglot.builtins import unicode_type
from polyglot.urllib import unquote, urlparse
from polyglot.queue import Queue, Empty
def image_extensions():

View File

@ -10,7 +10,6 @@ import os, errno, json, importlib, math, httplib, bz2, shutil, sys
from itertools import count
from io import BytesIO
from polyglot.builtins import map
from Queue import Queue, Empty
from threading import Thread, Event
from multiprocessing.pool import ThreadPool
@ -39,6 +38,7 @@ from calibre.utils.img import image_from_data, Canvas, optimize_png, optimize_jp
from calibre.utils.zipfile import ZipFile, ZIP_STORED
from calibre.utils.filenames import atomic_rename
from lzma.xz import compress, decompress
from polyglot.queue import Queue, Empty
IMAGE_EXTENSIONS = {'png', 'jpg', 'jpeg'}
THEME_COVER = 'icon-theme-cover.jpg'

View File

@ -8,7 +8,6 @@ Job management.
'''
import re, time
from Queue import Empty, Queue
from PyQt5.Qt import (QAbstractTableModel, QModelIndex, Qt, QPainter,
QTimer, pyqtSignal, QIcon, QDialog, QAbstractItemDelegate, QApplication,
@ -31,6 +30,7 @@ from calibre.gui2.widgets2 import Dialog
from calibre.utils.search_query_parser import SearchQueryParser, ParseException
from calibre.utils.icu import lower
from polyglot.builtins import unicode_type, range
from polyglot.queue import Empty, Queue
class AdaptSQP(SearchQueryParser):

View File

@ -9,7 +9,6 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
import itertools, operator, os, math
from types import MethodType
from threading import Event, Thread
from Queue import LifoQueue
from functools import wraps, partial
from textwrap import wrap
@ -31,6 +30,7 @@ from calibre.gui2.gestures import GestureManager
from calibre.gui2.library.caches import CoverCache, ThumbnailCache
from calibre.utils.config import prefs, tweaks
from polyglot.builtins import unicode_type, range
from polyglot.queue import LifoQueue
CM_TO_INCH = 0.393701
CACHE_FORMAT = 'PPM'

View File

@ -13,7 +13,6 @@ DEBUG_DIALOG = False
import os, time
from threading import Thread, Event
from operator import attrgetter
from Queue import Queue, Empty
from io import BytesIO
from PyQt5.Qt import (
@ -41,6 +40,7 @@ from calibre.utils.config import tweaks
from calibre.utils.ipc.simple_worker import fork_job, WorkerError
from calibre.ptempfile import TemporaryDirectory
from polyglot.builtins import unicode_type, range
from polyglot.queue import Queue, Empty
# }}}

View File

@ -9,7 +9,6 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
import traceback, errno, os, time, shutil
from collections import namedtuple, defaultdict
from tempfile import SpooledTemporaryFile
from Queue import Empty
from PyQt5.Qt import QObject, Qt, pyqtSignal
@ -26,6 +25,7 @@ from calibre.utils.formatter_functions import load_user_template_functions
from calibre.utils.ipc.pool import Pool, Failure
from calibre.library.save_to_disk import sanitize_args, get_path_components, find_plugboard, plugboard_save_to_disk_value
from polyglot.builtins import unicode_type
from polyglot.queue import Empty
BookId = namedtuple('BookId', 'title authors')

View File

@ -9,12 +9,12 @@ __docformat__ = 'restructuredtext en'
import traceback, base64
from contextlib import closing
from threading import Thread
from Queue import Queue
from calibre import browser
from calibre.constants import DEBUG
from calibre.utils.img import scale_image
from polyglot.builtins import range
from polyglot.queue import Queue
class GenericDownloadThreadPool(object):

View File

@ -9,11 +9,11 @@ __docformat__ = 'restructuredtext en'
import os, time, tempfile, json
from threading import Thread, RLock, Event
from Queue import Queue
from calibre.utils.ipc.job import BaseJob
from calibre.utils.logging import GUILog
from calibre.ptempfile import base_dir
from polyglot.queue import Queue
class ThreadedJob(BaseJob):
@ -245,5 +245,3 @@ class ThreadedJobServer(Thread):
queued_types.append(job.type)
ans.append(job)
return ans

View File

@ -8,7 +8,6 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
import os, sys
from threading import Thread, Event, RLock
from Queue import Queue
from contextlib import closing
from collections import namedtuple
@ -17,6 +16,7 @@ from calibre.gui2.tweak_book.completion.basic import Request
from calibre.gui2.tweak_book.completion.utils import DataError
from calibre.utils.ipc import eintr_retry_call
from calibre.utils.serialize import msgpack_loads, msgpack_dumps
from polyglot.queue import Queue
COMPLETION_REQUEST = 'completion request'
CLEAR_REQUEST = 'clear request'

View File

@ -11,7 +11,6 @@ from bisect import bisect_right
from base64 import b64encode
from polyglot.builtins import map, unicode_type
from threading import Thread
from Queue import Queue, Empty
from functools import partial
from PyQt5.Qt import (
@ -31,6 +30,7 @@ from calibre.gui2.viewer.config import config
from calibre.gui2.widgets2 import HistoryLineEdit2
from calibre.utils.ipc.simple_worker import offload_worker
from polyglot.urllib import urlparse
from polyglot.queue import Queue, Empty
shutdown = object()

View File

@ -8,7 +8,6 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
import shutil, os, errno
from threading import Thread
from Queue import LifoQueue, Empty
from PyQt5.Qt import (QObject, pyqtSignal, QLabel, QWidget, QHBoxLayout, Qt)
@ -18,6 +17,7 @@ from calibre.gui2.progress_indicator import ProgressIndicator
from calibre.utils import join_with_timeout
from calibre.utils.filenames import atomic_rename, format_permissions
from calibre.utils.ipc import RC
from polyglot.queue import LifoQueue, Empty
def save_dir_container(container, path):

View File

@ -10,7 +10,6 @@ __docformat__ = 'restructuredtext en'
'''The main GUI'''
import collections, os, sys, textwrap, time, gc, errno, re
from Queue import Queue, Empty
from threading import Thread
from collections import OrderedDict
from io import BytesIO
@ -54,6 +53,7 @@ from calibre.gui2.open_with import register_keyboard_shortcuts
from calibre.library import current_library_name
from calibre.srv.library_broker import GuiLibraryBroker
from polyglot.builtins import unicode_type, string_or_bytes
from polyglot.queue import Queue, Empty
class Listener(Thread): # {{{

View File

@ -11,7 +11,6 @@ import sqlite3 as sqlite, traceback, time, uuid, sys, os
import repr as reprlib
from sqlite3 import IntegrityError, OperationalError
from threading import Thread
from Queue import Queue
from threading import RLock
from datetime import datetime
from functools import partial
@ -23,6 +22,7 @@ from calibre.constants import iswindows, DEBUG, plugins
from calibre.utils.icu import sort_key
from calibre import prints
from polyglot.builtins import unicode_type
from polyglot.queue import Queue
from dateutil.tz import tzoffset

View File

@ -8,7 +8,6 @@ __copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
import os, sys, subprocess, signal, time, errno, socket, ssl
from threading import Thread, Lock
from Queue import Queue, Empty
from calibre.constants import islinux, iswindows, isosx
from calibre.srv.http_response import create_http_handler
@ -18,6 +17,7 @@ from calibre.srv.standalone import create_option_parser
from calibre.srv.utils import create_sock_pair
from calibre.srv.web_socket import DummyHandler
from calibre.utils.monotonic import monotonic
from polyglot.queue import Queue, Empty
MAX_RETRIES = 10

View File

@ -9,11 +9,11 @@ from itertools import count
from collections import namedtuple, deque
from functools import partial
from threading import RLock, Thread, Event
from Queue import Queue, Empty
from calibre import detect_ncpus, force_unicode
from calibre.utils.monotonic import monotonic
from calibre.utils.ipc.simple_worker import fork_job, WorkerError
from polyglot.queue import Queue, Empty
StartEvent = namedtuple('StartEvent', 'job_id name module function args kwargs callback data')
DoneEvent = namedtuple('DoneEvent', 'job_id')

View File

@ -8,7 +8,6 @@ __copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
import ssl, socket, select, os, traceback
from io import BytesIO
from Queue import Empty, Full
from functools import partial
from calibre import as_unicode
@ -26,6 +25,7 @@ from calibre.utils.logging import ThreadSafeLog
from calibre.utils.monotonic import monotonic
from calibre.utils.mdns import get_external_ip
from polyglot.builtins import range
from polyglot.queue import Empty, Full
READ, WRITE, RDWR, WAIT = 'READ', 'WRITE', 'RDWR', 'WAIT'
WAKEUP, JOB_DONE = bytes(bytearray(range(2)))

View File

@ -7,11 +7,11 @@ __license__ = 'GPL v3'
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
import sys
from Queue import Queue, Full
from threading import Thread
from calibre.utils.monotonic import monotonic
from polyglot.builtins import range
from polyglot.queue import Queue, Full
class Worker(Thread):

View File

@ -9,7 +9,6 @@ import httplib, os, weakref, socket
from base64 import standard_b64encode
from collections import deque
from hashlib import sha1
from Queue import Queue, Empty
from struct import unpack_from, pack, error as struct_error
from threading import Lock
@ -19,6 +18,7 @@ from calibre.srv.loop import ServerLoop, HandleInterrupt, WRITE, READ, RDWR, Con
from calibre.srv.http_response import HTTPConnection, create_http_handler
from calibre.srv.utils import DESIRED_SEND_BUFFER_SIZE
from calibre.utils.speedups import ReadOnlyFileBuffer
from polyglot.queue import Queue, Empty
speedup, err = plugins['speedup']
if not speedup:
raise RuntimeError('Failed to load speedup module with error: ' + err)

View File

@ -9,10 +9,10 @@ __docformat__ = 'restructuredtext en'
_count = 0
import time, io
from Queue import Queue, Empty
from calibre import prints
from calibre.constants import DEBUG
from polyglot.queue import Queue, Empty
class BaseJob(object):

View File

@ -9,7 +9,6 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
import os, sys
from threading import Thread
from collections import namedtuple
from Queue import Queue
from calibre import detect_ncpus, as_unicode, prints
from calibre.constants import iswindows, DEBUG
@ -17,6 +16,7 @@ from calibre.ptempfile import PersistentTemporaryFile
from calibre.utils import join_with_timeout
from calibre.utils.ipc import eintr_retry_call
from calibre.utils.serialize import msgpack_dumps, msgpack_loads, pickle_dumps, pickle_loads
from polyglot.queue import Queue
Job = namedtuple('Job', 'id module func args kwargs')
Result = namedtuple('Result', 'value err traceback')

View File

@ -17,7 +17,6 @@ from binascii import hexlify
from collections import deque
from math import ceil
from multiprocessing.connection import Listener, arbitrary_address
from Queue import Empty, Queue
from threading import RLock, Thread
from calibre import detect_ncpus as cpu_count
@ -28,6 +27,7 @@ from calibre.utils.ipc.launch import Worker
from calibre.utils.ipc.worker import PARALLEL_FUNCS
from calibre.utils.serialize import msgpack_dumps, pickle_loads
from polyglot.builtins import string_or_bytes, environ_item
from polyglot.queue import Empty, Queue
_counter = 0

View File

@ -10,7 +10,6 @@ __docformat__ = 'restructuredtext en'
import os, sys, importlib
from multiprocessing.connection import Client
from threading import Thread
from Queue import Queue
from contextlib import closing
from binascii import unhexlify
from zipimport import ZipImportError
@ -19,6 +18,7 @@ from calibre import prints
from calibre.constants import iswindows, isosx
from calibre.utils.ipc import eintr_retry_call
from calibre.utils.serialize import msgpack_loads, pickle_dumps
from polyglot.queue import Queue
PARALLEL_FUNCS = {
'lrfviewer' :

View File

@ -9,7 +9,6 @@ import atexit, os, sys
from math import ceil
from unicodedata import normalize
from threading import Thread, Lock
from Queue import Queue
from operator import itemgetter
from collections import OrderedDict
from itertools import islice
@ -20,6 +19,7 @@ from polyglot.builtins import map, unicode_type, range
from calibre import detect_ncpus as cpu_count, as_unicode
from calibre.constants import plugins, filesystem_encoding
from calibre.utils.icu import primary_sort_key, primary_find, primary_collator
from polyglot.queue import Queue
DEFAULT_LEVEL1 = '/'
DEFAULT_LEVEL2 = '-_ 0123456789'

View File

@ -14,7 +14,6 @@ import subprocess
import sys
from functools import partial
from io import BytesIO
from Queue import Empty, Queue
from threading import Thread, local
from calibre import force_unicode
@ -24,6 +23,7 @@ from calibre.utils.terminal import ANSIStream
from duktape import Context, JSError, to_python
from lzma.xz import compress, decompress
from polyglot.builtins import range
from polyglot.queue import Empty, Queue
COMPILER_PATH = 'rapydscript/compiler.js.xz'

View File

@ -48,7 +48,7 @@ __license__ = 'Python license'
# standard library modules
import threading
import Queue
from polyglot import queue
# exceptions
@ -75,7 +75,7 @@ class WorkerThread(threading.Thread):
def __init__(self, requestsQueue, resultsQueue, **kwds):
"""Set up thread in daemonic mode and start it immediatedly.
requestsQueue and resultQueue are instances of Queue.Queue passed
requestsQueue and resultQueue are instances of queue.Queue passed
by the ThreadPool class when it creates a new worker thread.
"""
@ -174,8 +174,8 @@ class ThreadPool:
more work requests in it (see putRequest method).
"""
self.requestsQueue = Queue.Queue(q_size)
self.resultsQueue = Queue.Queue()
self.requestsQueue = queue.Queue(q_size)
self.resultsQueue = queue.Queue()
self.workers = []
self.workRequests = {}
self.createWorkers(num_workers)
@ -223,7 +223,7 @@ class ThreadPool:
(request.exception and request.exc_callback):
request.callback(request, result)
del self.workRequests[request.requestID]
except Queue.Empty:
except queue.Empty:
break
def wait(self, sleep=0):

10
src/polyglot/queue.py Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2019, Eli Schwartz <eschwartz@archlinux.org>
from polyglot.builtins import is_py3
if is_py3:
from queue import * # noqa
else:
from Queue import * # noqa