mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
python3: add polyglot.queue wrapper
This commit is contained in:
parent
ea6a210e70
commit
83b055122a
@ -8,11 +8,11 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import os, tempfile, shutil, errno, time, atexit
|
import os, tempfile, shutil, errno, time, atexit
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue
|
|
||||||
|
|
||||||
from calibre.ptempfile import remove_dir
|
from calibre.ptempfile import remove_dir
|
||||||
from calibre.utils.filenames import remove_dir_if_empty
|
from calibre.utils.filenames import remove_dir_if_empty
|
||||||
from calibre.utils.recycle_bin import delete_tree, delete_file
|
from calibre.utils.recycle_bin import delete_tree, delete_file
|
||||||
|
from polyglot.queue import Queue
|
||||||
|
|
||||||
|
|
||||||
class DeleteService(Thread):
|
class DeleteService(Thread):
|
||||||
@ -159,4 +159,3 @@ def has_jobs():
|
|||||||
if __ds is not None:
|
if __ds is not None:
|
||||||
return (not __ds.requests.empty()) or __ds.requests.unfinished_tasks
|
return (not __ds.requests.empty()) or __ds.requests.unfinished_tasks
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ import socket, select, json, os, traceback, time, sys, random
|
|||||||
import posixpath
|
import posixpath
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import hashlib, threading
|
import hashlib, threading
|
||||||
import Queue
|
|
||||||
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from errno import EAGAIN, EINTR
|
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)
|
unpublish_zeroconf, get_all_ips)
|
||||||
from calibre.utils.socket_inheritance import set_socket_inherit
|
from calibre.utils.socket_inheritance import set_socket_inherit
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
from polyglot import queue
|
||||||
|
|
||||||
|
|
||||||
def synchronous(tlockname):
|
def synchronous(tlockname):
|
||||||
@ -103,7 +103,7 @@ class ConnectionListener(Thread):
|
|||||||
{'otherDevice': d.get_gui_name()})
|
{'otherDevice': d.get_gui_name()})
|
||||||
self.driver._send_byte_string(device_socket, (b'%d' % len(s)) + s)
|
self.driver._send_byte_string(device_socket, (b'%d' % len(s)) + s)
|
||||||
sock.close()
|
sock.close()
|
||||||
except Queue.Empty:
|
except queue.Empty:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if getattr(self.driver, 'broadcast_socket', None) is not None:
|
if getattr(self.driver, 'broadcast_socket', None) is not None:
|
||||||
@ -148,7 +148,7 @@ class ConnectionListener(Thread):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.driver.connection_queue.put_nowait(device_socket)
|
self.driver.connection_queue.put_nowait(device_socket)
|
||||||
except Queue.Full:
|
except queue.Full:
|
||||||
self._close_socket(device_socket)
|
self._close_socket(device_socket)
|
||||||
device_socket = None
|
device_socket = None
|
||||||
self.driver._debug('driver is not answering')
|
self.driver._debug('driver is not answering')
|
||||||
@ -993,7 +993,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
except Queue.Empty:
|
except queue.Empty:
|
||||||
self.is_connected = False
|
self.is_connected = False
|
||||||
return self if self.is_connected else None
|
return self if self.is_connected else None
|
||||||
return None
|
return None
|
||||||
@ -1969,7 +1969,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
message = 'attaching port to broadcast socket failed. This is not fatal.'
|
message = 'attaching port to broadcast socket failed. This is not fatal.'
|
||||||
self._debug(message)
|
self._debug(message)
|
||||||
|
|
||||||
self.connection_queue = Queue.Queue(1)
|
self.connection_queue = queue.Queue(1)
|
||||||
self.connection_listener = ConnectionListener(self)
|
self.connection_listener = ConnectionListener(self)
|
||||||
self.connection_listener.start()
|
self.connection_listener.start()
|
||||||
return message
|
return message
|
||||||
|
@ -8,7 +8,6 @@ Based on ideas from comiclrf created by FangornUK.
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import os, traceback, time
|
import os, traceback, time
|
||||||
from Queue import Empty
|
|
||||||
|
|
||||||
from calibre import extract, prints, walk
|
from calibre import extract, prints, walk
|
||||||
from calibre.constants import filesystem_encoding
|
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.server import Server
|
||||||
from calibre.utils.ipc.job import ParallelJob
|
from calibre.utils.ipc.job import ParallelJob
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
from polyglot.queue import Empty
|
||||||
|
|
||||||
# If the specified screen has either dimension larger than this value, no image
|
# 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)
|
# rescaling is done (we assume that it is a tablet output profile)
|
||||||
|
@ -8,7 +8,6 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os, tempfile, time
|
import os, tempfile, time
|
||||||
from Queue import Queue, Empty
|
|
||||||
from threading import Event
|
from threading import Event
|
||||||
|
|
||||||
from calibre.customize.ui import all_metadata_plugins
|
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 import check_isbn
|
||||||
from calibre.ebooks.metadata.sources.base import create_log, get_cached_cover_urls
|
from calibre.ebooks.metadata.sources.base import create_log, get_cached_cover_urls
|
||||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
from calibre.ebooks.metadata.sources.prefs import msprefs
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
|
|
||||||
|
|
||||||
def isbn_test(isbn):
|
def isbn_test(isbn):
|
||||||
|
@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
|||||||
import os
|
import os
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from Queue import Empty, Queue
|
|
||||||
from threading import Event, Thread
|
from threading import Event, Thread
|
||||||
|
|
||||||
from calibre.customize.ui import metadata_plugins
|
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.ebooks.metadata.sources.update import patch_plugins
|
||||||
from calibre.utils.date import as_utc
|
from calibre.utils.date import as_utc
|
||||||
from calibre.utils.logging import GUILog
|
from calibre.utils.logging import GUILog
|
||||||
|
from polyglot.queue import Empty, Queue
|
||||||
|
|
||||||
|
|
||||||
def merge_result(oldmi, newmi, ensure_fields=None):
|
def merge_result(oldmi, newmi, ensure_fields=None):
|
||||||
|
@ -9,7 +9,6 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import os
|
import os
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue, Empty
|
|
||||||
|
|
||||||
from calibre import browser
|
from calibre import browser
|
||||||
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES, urlunquote, XHTML_MIME
|
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 calibre.ebooks.oeb.polish.check.base import BaseError, WARN, INFO
|
||||||
from polyglot.builtins import map, range
|
from polyglot.builtins import map, range
|
||||||
from polyglot.urllib import urlparse
|
from polyglot.urllib import urlparse
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
|
|
||||||
|
|
||||||
class BadLink(BaseError):
|
class BadLink(BaseError):
|
||||||
|
@ -7,10 +7,10 @@ from __future__ import (unicode_literals, division, absolute_import,
|
|||||||
import os
|
import os
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
from Queue import Queue, Empty
|
|
||||||
|
|
||||||
from calibre import detect_ncpus, human_readable, force_unicode, filesystem_encoding
|
from calibre import detect_ncpus, human_readable, force_unicode, filesystem_encoding
|
||||||
from polyglot.builtins import range
|
from polyglot.builtins import range
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
|
|
||||||
|
|
||||||
class Worker(Thread):
|
class Worker(Thread):
|
||||||
|
@ -3,7 +3,6 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
""" The GUI """
|
""" The GUI """
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import Queue
|
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import threading
|
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.file_type_icons import EXT_MAP
|
||||||
from calibre.utils.localization import get_lang
|
from calibre.utils.localization import get_lang
|
||||||
from polyglot.builtins import unicode_type, string_or_bytes, range
|
from polyglot.builtins import unicode_type, string_or_bytes, range
|
||||||
|
from polyglot import queue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
NO_URL_FORMATTING = QUrl.None_
|
NO_URL_FORMATTING = QUrl.None_
|
||||||
@ -502,7 +502,7 @@ class FunctionDispatcher(QObject):
|
|||||||
if not queued:
|
if not queued:
|
||||||
typ = Qt.AutoConnection if queued is None else Qt.DirectConnection
|
typ = Qt.AutoConnection if queued is None else Qt.DirectConnection
|
||||||
self.dispatch_signal.connect(self.dispatch, type=typ)
|
self.dispatch_signal.connect(self.dispatch, type=typ)
|
||||||
self.q = Queue.Queue()
|
self.q = queue.Queue()
|
||||||
self.lock = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
|
@ -9,7 +9,6 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import shutil, os, weakref, traceback, tempfile, time
|
import shutil, os, weakref, traceback, tempfile, time
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from Queue import Empty
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from polyglot.builtins import map, unicode_type, string_or_bytes
|
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 import join_with_timeout
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.utils.ipc.pool import Pool, Failure
|
from calibre.utils.ipc.pool import Pool, Failure
|
||||||
|
from polyglot.queue import Empty
|
||||||
|
|
||||||
|
|
||||||
def validate_source(source, parent=None): # {{{
|
def validate_source(source, parent=None): # {{{
|
||||||
|
@ -3,7 +3,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
# Imports {{{
|
# Imports {{{
|
||||||
import os, traceback, Queue, time, io, re, sys, weakref
|
import os, traceback, time, io, re, sys, weakref
|
||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
|
|
||||||
from PyQt5.Qt import (
|
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.library.save_to_disk import find_plugboard
|
||||||
from calibre.ptempfile import PersistentTemporaryFile, force_unicode as filename_to_unicode
|
from calibre.ptempfile import PersistentTemporaryFile, force_unicode as filename_to_unicode
|
||||||
from polyglot.builtins import unicode_type, string_or_bytes
|
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.sleep_time = sleep_time
|
||||||
self.connected_slot = connected_slot
|
self.connected_slot = connected_slot
|
||||||
self.allow_connect_slot = allow_connect_slot
|
self.allow_connect_slot = allow_connect_slot
|
||||||
self.jobs = Queue.Queue(0)
|
self.jobs = queue.Queue(0)
|
||||||
self.job_steps = Queue.Queue(0)
|
self.job_steps = queue.Queue(0)
|
||||||
self.keep_going = True
|
self.keep_going = True
|
||||||
self.job_manager = job_manager
|
self.job_manager = job_manager
|
||||||
self.reported_errors = set([])
|
self.reported_errors = set([])
|
||||||
@ -163,7 +164,7 @@ class DeviceManager(Thread): # {{{
|
|||||||
self.connected_device = None
|
self.connected_device = None
|
||||||
self.connected_device_kind = None
|
self.connected_device_kind = None
|
||||||
self.ejected_devices = set([])
|
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_slot = open_feedback_slot
|
||||||
self.open_feedback_only_once_seen = set()
|
self.open_feedback_only_once_seen = set()
|
||||||
self.after_callback_feedback_slot = after_callback_feedback_slot
|
self.after_callback_feedback_slot = after_callback_feedback_slot
|
||||||
@ -241,7 +242,7 @@ class DeviceManager(Thread): # {{{
|
|||||||
try:
|
try:
|
||||||
job = self.jobs.get_nowait()
|
job = self.jobs.get_nowait()
|
||||||
job.abort(Exception(_('Device no longer connected.')))
|
job.abort(Exception(_('Device no longer connected.')))
|
||||||
except Queue.Empty:
|
except queue.Empty:
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
self.connected_device.post_yank_cleanup()
|
self.connected_device.post_yank_cleanup()
|
||||||
@ -358,13 +359,13 @@ class DeviceManager(Thread): # {{{
|
|||||||
if not self.job_steps.empty():
|
if not self.job_steps.empty():
|
||||||
try:
|
try:
|
||||||
return self.job_steps.get_nowait()
|
return self.job_steps.get_nowait()
|
||||||
except Queue.Empty:
|
except queue.Empty:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not self.jobs.empty():
|
if not self.jobs.empty():
|
||||||
try:
|
try:
|
||||||
return self.jobs.get_nowait()
|
return self.jobs.get_nowait()
|
||||||
except Queue.Empty:
|
except queue.Empty:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def run_startup(self, dev):
|
def run_startup(self, dev):
|
||||||
@ -391,7 +392,7 @@ class DeviceManager(Thread): # {{{
|
|||||||
try:
|
try:
|
||||||
(kls,device_kind, folder_path) = \
|
(kls,device_kind, folder_path) = \
|
||||||
self.mount_connection_requests.get_nowait()
|
self.mount_connection_requests.get_nowait()
|
||||||
except Queue.Empty:
|
except queue.Empty:
|
||||||
break
|
break
|
||||||
if kls is not None:
|
if kls is not None:
|
||||||
try:
|
try:
|
||||||
|
@ -9,7 +9,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import posixpath, os, re
|
import posixpath, os, re
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue, Empty
|
|
||||||
|
|
||||||
from PyQt5.Qt import QPixmap, Qt, QDialog, QLabel, QVBoxLayout, \
|
from PyQt5.Qt import QPixmap, Qt, QDialog, QLabel, QVBoxLayout, \
|
||||||
QDialogButtonBox, QProgressBar, QTimer, QUrl, QImageReader
|
QDialogButtonBox, QProgressBar, QTimer, QUrl, QImageReader
|
||||||
@ -21,6 +20,7 @@ from calibre.gui2 import error_dialog
|
|||||||
from calibre.utils.imghdr import what
|
from calibre.utils.imghdr import what
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
from polyglot.urllib import unquote, urlparse
|
from polyglot.urllib import unquote, urlparse
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
|
|
||||||
|
|
||||||
def image_extensions():
|
def image_extensions():
|
||||||
|
@ -10,7 +10,6 @@ import os, errno, json, importlib, math, httplib, bz2, shutil, sys
|
|||||||
from itertools import count
|
from itertools import count
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from polyglot.builtins import map
|
from polyglot.builtins import map
|
||||||
from Queue import Queue, Empty
|
|
||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
from multiprocessing.pool import ThreadPool
|
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.zipfile import ZipFile, ZIP_STORED
|
||||||
from calibre.utils.filenames import atomic_rename
|
from calibre.utils.filenames import atomic_rename
|
||||||
from lzma.xz import compress, decompress
|
from lzma.xz import compress, decompress
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
|
|
||||||
IMAGE_EXTENSIONS = {'png', 'jpg', 'jpeg'}
|
IMAGE_EXTENSIONS = {'png', 'jpg', 'jpeg'}
|
||||||
THEME_COVER = 'icon-theme-cover.jpg'
|
THEME_COVER = 'icon-theme-cover.jpg'
|
||||||
|
@ -8,7 +8,6 @@ Job management.
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import re, time
|
import re, time
|
||||||
from Queue import Empty, Queue
|
|
||||||
|
|
||||||
from PyQt5.Qt import (QAbstractTableModel, QModelIndex, Qt, QPainter,
|
from PyQt5.Qt import (QAbstractTableModel, QModelIndex, Qt, QPainter,
|
||||||
QTimer, pyqtSignal, QIcon, QDialog, QAbstractItemDelegate, QApplication,
|
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.search_query_parser import SearchQueryParser, ParseException
|
||||||
from calibre.utils.icu import lower
|
from calibre.utils.icu import lower
|
||||||
from polyglot.builtins import unicode_type, range
|
from polyglot.builtins import unicode_type, range
|
||||||
|
from polyglot.queue import Empty, Queue
|
||||||
|
|
||||||
|
|
||||||
class AdaptSQP(SearchQueryParser):
|
class AdaptSQP(SearchQueryParser):
|
||||||
|
@ -9,7 +9,6 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import itertools, operator, os, math
|
import itertools, operator, os, math
|
||||||
from types import MethodType
|
from types import MethodType
|
||||||
from threading import Event, Thread
|
from threading import Event, Thread
|
||||||
from Queue import LifoQueue
|
|
||||||
from functools import wraps, partial
|
from functools import wraps, partial
|
||||||
from textwrap import wrap
|
from textwrap import wrap
|
||||||
|
|
||||||
@ -31,6 +30,7 @@ from calibre.gui2.gestures import GestureManager
|
|||||||
from calibre.gui2.library.caches import CoverCache, ThumbnailCache
|
from calibre.gui2.library.caches import CoverCache, ThumbnailCache
|
||||||
from calibre.utils.config import prefs, tweaks
|
from calibre.utils.config import prefs, tweaks
|
||||||
from polyglot.builtins import unicode_type, range
|
from polyglot.builtins import unicode_type, range
|
||||||
|
from polyglot.queue import LifoQueue
|
||||||
|
|
||||||
CM_TO_INCH = 0.393701
|
CM_TO_INCH = 0.393701
|
||||||
CACHE_FORMAT = 'PPM'
|
CACHE_FORMAT = 'PPM'
|
||||||
|
@ -13,7 +13,6 @@ DEBUG_DIALOG = False
|
|||||||
import os, time
|
import os, time
|
||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from Queue import Queue, Empty
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from PyQt5.Qt import (
|
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.utils.ipc.simple_worker import fork_job, WorkerError
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
from polyglot.builtins import unicode_type, range
|
from polyglot.builtins import unicode_type, range
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import traceback, errno, os, time, shutil
|
import traceback, errno, os, time, shutil
|
||||||
from collections import namedtuple, defaultdict
|
from collections import namedtuple, defaultdict
|
||||||
from tempfile import SpooledTemporaryFile
|
from tempfile import SpooledTemporaryFile
|
||||||
from Queue import Empty
|
|
||||||
|
|
||||||
from PyQt5.Qt import QObject, Qt, pyqtSignal
|
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.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 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.builtins import unicode_type
|
||||||
|
from polyglot.queue import Empty
|
||||||
|
|
||||||
BookId = namedtuple('BookId', 'title authors')
|
BookId = namedtuple('BookId', 'title authors')
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import traceback, base64
|
import traceback, base64
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue
|
|
||||||
|
|
||||||
from calibre import browser
|
from calibre import browser
|
||||||
from calibre.constants import DEBUG
|
from calibre.constants import DEBUG
|
||||||
from calibre.utils.img import scale_image
|
from calibre.utils.img import scale_image
|
||||||
from polyglot.builtins import range
|
from polyglot.builtins import range
|
||||||
|
from polyglot.queue import Queue
|
||||||
|
|
||||||
|
|
||||||
class GenericDownloadThreadPool(object):
|
class GenericDownloadThreadPool(object):
|
||||||
|
@ -9,11 +9,11 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import os, time, tempfile, json
|
import os, time, tempfile, json
|
||||||
from threading import Thread, RLock, Event
|
from threading import Thread, RLock, Event
|
||||||
from Queue import Queue
|
|
||||||
|
|
||||||
from calibre.utils.ipc.job import BaseJob
|
from calibre.utils.ipc.job import BaseJob
|
||||||
from calibre.utils.logging import GUILog
|
from calibre.utils.logging import GUILog
|
||||||
from calibre.ptempfile import base_dir
|
from calibre.ptempfile import base_dir
|
||||||
|
from polyglot.queue import Queue
|
||||||
|
|
||||||
|
|
||||||
class ThreadedJob(BaseJob):
|
class ThreadedJob(BaseJob):
|
||||||
@ -245,5 +245,3 @@ class ThreadedJobServer(Thread):
|
|||||||
queued_types.append(job.type)
|
queued_types.append(job.type)
|
||||||
ans.append(job)
|
ans.append(job)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
from threading import Thread, Event, RLock
|
from threading import Thread, Event, RLock
|
||||||
from Queue import Queue
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from collections import namedtuple
|
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.gui2.tweak_book.completion.utils import DataError
|
||||||
from calibre.utils.ipc import eintr_retry_call
|
from calibre.utils.ipc import eintr_retry_call
|
||||||
from calibre.utils.serialize import msgpack_loads, msgpack_dumps
|
from calibre.utils.serialize import msgpack_loads, msgpack_dumps
|
||||||
|
from polyglot.queue import Queue
|
||||||
|
|
||||||
COMPLETION_REQUEST = 'completion request'
|
COMPLETION_REQUEST = 'completion request'
|
||||||
CLEAR_REQUEST = 'clear request'
|
CLEAR_REQUEST = 'clear request'
|
||||||
|
@ -11,7 +11,6 @@ from bisect import bisect_right
|
|||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from polyglot.builtins import map, unicode_type
|
from polyglot.builtins import map, unicode_type
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue, Empty
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
@ -31,6 +30,7 @@ from calibre.gui2.viewer.config import config
|
|||||||
from calibre.gui2.widgets2 import HistoryLineEdit2
|
from calibre.gui2.widgets2 import HistoryLineEdit2
|
||||||
from calibre.utils.ipc.simple_worker import offload_worker
|
from calibre.utils.ipc.simple_worker import offload_worker
|
||||||
from polyglot.urllib import urlparse
|
from polyglot.urllib import urlparse
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
|
|
||||||
shutdown = object()
|
shutdown = object()
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import shutil, os, errno
|
import shutil, os, errno
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import LifoQueue, Empty
|
|
||||||
|
|
||||||
from PyQt5.Qt import (QObject, pyqtSignal, QLabel, QWidget, QHBoxLayout, Qt)
|
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 import join_with_timeout
|
||||||
from calibre.utils.filenames import atomic_rename, format_permissions
|
from calibre.utils.filenames import atomic_rename, format_permissions
|
||||||
from calibre.utils.ipc import RC
|
from calibre.utils.ipc import RC
|
||||||
|
from polyglot.queue import LifoQueue, Empty
|
||||||
|
|
||||||
|
|
||||||
def save_dir_container(container, path):
|
def save_dir_container(container, path):
|
||||||
|
@ -10,7 +10,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
'''The main GUI'''
|
'''The main GUI'''
|
||||||
|
|
||||||
import collections, os, sys, textwrap, time, gc, errno, re
|
import collections, os, sys, textwrap, time, gc, errno, re
|
||||||
from Queue import Queue, Empty
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from io import BytesIO
|
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.library import current_library_name
|
||||||
from calibre.srv.library_broker import GuiLibraryBroker
|
from calibre.srv.library_broker import GuiLibraryBroker
|
||||||
from polyglot.builtins import unicode_type, string_or_bytes
|
from polyglot.builtins import unicode_type, string_or_bytes
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
|
|
||||||
|
|
||||||
class Listener(Thread): # {{{
|
class Listener(Thread): # {{{
|
||||||
|
@ -11,7 +11,6 @@ import sqlite3 as sqlite, traceback, time, uuid, sys, os
|
|||||||
import repr as reprlib
|
import repr as reprlib
|
||||||
from sqlite3 import IntegrityError, OperationalError
|
from sqlite3 import IntegrityError, OperationalError
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue
|
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@ -23,6 +22,7 @@ from calibre.constants import iswindows, DEBUG, plugins
|
|||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
from polyglot.queue import Queue
|
||||||
|
|
||||||
from dateutil.tz import tzoffset
|
from dateutil.tz import tzoffset
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ __copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import os, sys, subprocess, signal, time, errno, socket, ssl
|
import os, sys, subprocess, signal, time, errno, socket, ssl
|
||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
from Queue import Queue, Empty
|
|
||||||
|
|
||||||
from calibre.constants import islinux, iswindows, isosx
|
from calibre.constants import islinux, iswindows, isosx
|
||||||
from calibre.srv.http_response import create_http_handler
|
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.utils import create_sock_pair
|
||||||
from calibre.srv.web_socket import DummyHandler
|
from calibre.srv.web_socket import DummyHandler
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
|
|
||||||
MAX_RETRIES = 10
|
MAX_RETRIES = 10
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@ from itertools import count
|
|||||||
from collections import namedtuple, deque
|
from collections import namedtuple, deque
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from threading import RLock, Thread, Event
|
from threading import RLock, Thread, Event
|
||||||
from Queue import Queue, Empty
|
|
||||||
|
|
||||||
from calibre import detect_ncpus, force_unicode
|
from calibre import detect_ncpus, force_unicode
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
from calibre.utils.ipc.simple_worker import fork_job, WorkerError
|
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')
|
StartEvent = namedtuple('StartEvent', 'job_id name module function args kwargs callback data')
|
||||||
DoneEvent = namedtuple('DoneEvent', 'job_id')
|
DoneEvent = namedtuple('DoneEvent', 'job_id')
|
||||||
|
@ -8,7 +8,6 @@ __copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import ssl, socket, select, os, traceback
|
import ssl, socket, select, os, traceback
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from Queue import Empty, Full
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
@ -26,6 +25,7 @@ from calibre.utils.logging import ThreadSafeLog
|
|||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
from calibre.utils.mdns import get_external_ip
|
from calibre.utils.mdns import get_external_ip
|
||||||
from polyglot.builtins import range
|
from polyglot.builtins import range
|
||||||
|
from polyglot.queue import Empty, Full
|
||||||
|
|
||||||
READ, WRITE, RDWR, WAIT = 'READ', 'WRITE', 'RDWR', 'WAIT'
|
READ, WRITE, RDWR, WAIT = 'READ', 'WRITE', 'RDWR', 'WAIT'
|
||||||
WAKEUP, JOB_DONE = bytes(bytearray(range(2)))
|
WAKEUP, JOB_DONE = bytes(bytearray(range(2)))
|
||||||
|
@ -7,11 +7,11 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from Queue import Queue, Full
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
from polyglot.builtins import range
|
from polyglot.builtins import range
|
||||||
|
from polyglot.queue import Queue, Full
|
||||||
|
|
||||||
|
|
||||||
class Worker(Thread):
|
class Worker(Thread):
|
||||||
|
@ -9,7 +9,6 @@ import httplib, os, weakref, socket
|
|||||||
from base64 import standard_b64encode
|
from base64 import standard_b64encode
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from Queue import Queue, Empty
|
|
||||||
from struct import unpack_from, pack, error as struct_error
|
from struct import unpack_from, pack, error as struct_error
|
||||||
from threading import Lock
|
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.http_response import HTTPConnection, create_http_handler
|
||||||
from calibre.srv.utils import DESIRED_SEND_BUFFER_SIZE
|
from calibre.srv.utils import DESIRED_SEND_BUFFER_SIZE
|
||||||
from calibre.utils.speedups import ReadOnlyFileBuffer
|
from calibre.utils.speedups import ReadOnlyFileBuffer
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
speedup, err = plugins['speedup']
|
speedup, err = plugins['speedup']
|
||||||
if not speedup:
|
if not speedup:
|
||||||
raise RuntimeError('Failed to load speedup module with error: ' + err)
|
raise RuntimeError('Failed to load speedup module with error: ' + err)
|
||||||
|
@ -9,10 +9,10 @@ __docformat__ = 'restructuredtext en'
|
|||||||
_count = 0
|
_count = 0
|
||||||
|
|
||||||
import time, io
|
import time, io
|
||||||
from Queue import Queue, Empty
|
|
||||||
|
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import DEBUG
|
from calibre.constants import DEBUG
|
||||||
|
from polyglot.queue import Queue, Empty
|
||||||
|
|
||||||
|
|
||||||
class BaseJob(object):
|
class BaseJob(object):
|
||||||
|
@ -9,7 +9,6 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import os, sys
|
import os, sys
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from Queue import Queue
|
|
||||||
|
|
||||||
from calibre import detect_ncpus, as_unicode, prints
|
from calibre import detect_ncpus, as_unicode, prints
|
||||||
from calibre.constants import iswindows, DEBUG
|
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 import join_with_timeout
|
||||||
from calibre.utils.ipc import eintr_retry_call
|
from calibre.utils.ipc import eintr_retry_call
|
||||||
from calibre.utils.serialize import msgpack_dumps, msgpack_loads, pickle_dumps, pickle_loads
|
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')
|
Job = namedtuple('Job', 'id module func args kwargs')
|
||||||
Result = namedtuple('Result', 'value err traceback')
|
Result = namedtuple('Result', 'value err traceback')
|
||||||
|
@ -17,7 +17,6 @@ from binascii import hexlify
|
|||||||
from collections import deque
|
from collections import deque
|
||||||
from math import ceil
|
from math import ceil
|
||||||
from multiprocessing.connection import Listener, arbitrary_address
|
from multiprocessing.connection import Listener, arbitrary_address
|
||||||
from Queue import Empty, Queue
|
|
||||||
from threading import RLock, Thread
|
from threading import RLock, Thread
|
||||||
|
|
||||||
from calibre import detect_ncpus as cpu_count
|
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.ipc.worker import PARALLEL_FUNCS
|
||||||
from calibre.utils.serialize import msgpack_dumps, pickle_loads
|
from calibre.utils.serialize import msgpack_dumps, pickle_loads
|
||||||
from polyglot.builtins import string_or_bytes, environ_item
|
from polyglot.builtins import string_or_bytes, environ_item
|
||||||
|
from polyglot.queue import Empty, Queue
|
||||||
|
|
||||||
|
|
||||||
_counter = 0
|
_counter = 0
|
||||||
|
@ -10,7 +10,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os, sys, importlib
|
import os, sys, importlib
|
||||||
from multiprocessing.connection import Client
|
from multiprocessing.connection import Client
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
from zipimport import ZipImportError
|
from zipimport import ZipImportError
|
||||||
@ -19,6 +18,7 @@ from calibre import prints
|
|||||||
from calibre.constants import iswindows, isosx
|
from calibre.constants import iswindows, isosx
|
||||||
from calibre.utils.ipc import eintr_retry_call
|
from calibre.utils.ipc import eintr_retry_call
|
||||||
from calibre.utils.serialize import msgpack_loads, pickle_dumps
|
from calibre.utils.serialize import msgpack_loads, pickle_dumps
|
||||||
|
from polyglot.queue import Queue
|
||||||
|
|
||||||
PARALLEL_FUNCS = {
|
PARALLEL_FUNCS = {
|
||||||
'lrfviewer' :
|
'lrfviewer' :
|
||||||
|
@ -9,7 +9,6 @@ import atexit, os, sys
|
|||||||
from math import ceil
|
from math import ceil
|
||||||
from unicodedata import normalize
|
from unicodedata import normalize
|
||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
from Queue import Queue
|
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from itertools import islice
|
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 import detect_ncpus as cpu_count, as_unicode
|
||||||
from calibre.constants import plugins, filesystem_encoding
|
from calibre.constants import plugins, filesystem_encoding
|
||||||
from calibre.utils.icu import primary_sort_key, primary_find, primary_collator
|
from calibre.utils.icu import primary_sort_key, primary_find, primary_collator
|
||||||
|
from polyglot.queue import Queue
|
||||||
|
|
||||||
DEFAULT_LEVEL1 = '/'
|
DEFAULT_LEVEL1 = '/'
|
||||||
DEFAULT_LEVEL2 = '-_ 0123456789'
|
DEFAULT_LEVEL2 = '-_ 0123456789'
|
||||||
|
@ -14,7 +14,6 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from Queue import Empty, Queue
|
|
||||||
from threading import Thread, local
|
from threading import Thread, local
|
||||||
|
|
||||||
from calibre import force_unicode
|
from calibre import force_unicode
|
||||||
@ -24,6 +23,7 @@ from calibre.utils.terminal import ANSIStream
|
|||||||
from duktape import Context, JSError, to_python
|
from duktape import Context, JSError, to_python
|
||||||
from lzma.xz import compress, decompress
|
from lzma.xz import compress, decompress
|
||||||
from polyglot.builtins import range
|
from polyglot.builtins import range
|
||||||
|
from polyglot.queue import Empty, Queue
|
||||||
|
|
||||||
COMPILER_PATH = 'rapydscript/compiler.js.xz'
|
COMPILER_PATH = 'rapydscript/compiler.js.xz'
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ __license__ = 'Python license'
|
|||||||
|
|
||||||
# standard library modules
|
# standard library modules
|
||||||
import threading
|
import threading
|
||||||
import Queue
|
from polyglot import queue
|
||||||
|
|
||||||
# exceptions
|
# exceptions
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class WorkerThread(threading.Thread):
|
|||||||
def __init__(self, requestsQueue, resultsQueue, **kwds):
|
def __init__(self, requestsQueue, resultsQueue, **kwds):
|
||||||
"""Set up thread in daemonic mode and start it immediatedly.
|
"""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.
|
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).
|
more work requests in it (see putRequest method).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.requestsQueue = Queue.Queue(q_size)
|
self.requestsQueue = queue.Queue(q_size)
|
||||||
self.resultsQueue = Queue.Queue()
|
self.resultsQueue = queue.Queue()
|
||||||
self.workers = []
|
self.workers = []
|
||||||
self.workRequests = {}
|
self.workRequests = {}
|
||||||
self.createWorkers(num_workers)
|
self.createWorkers(num_workers)
|
||||||
@ -223,7 +223,7 @@ class ThreadPool:
|
|||||||
(request.exception and request.exc_callback):
|
(request.exception and request.exc_callback):
|
||||||
request.callback(request, result)
|
request.callback(request, result)
|
||||||
del self.workRequests[request.requestID]
|
del self.workRequests[request.requestID]
|
||||||
except Queue.Empty:
|
except queue.Empty:
|
||||||
break
|
break
|
||||||
|
|
||||||
def wait(self, sleep=0):
|
def wait(self, sleep=0):
|
||||||
|
10
src/polyglot/queue.py
Normal file
10
src/polyglot/queue.py
Normal 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
|
Loading…
x
Reference in New Issue
Block a user