mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-02-06 17:14:17 +01:00
Parallel jobs can now specify how many cores they use. Have comic conversion jobs specify they use all cores
This commit is contained in:
parent
926e3fa545
commit
fa7f05ec41
5 changed files with 20 additions and 2 deletions
|
|
@ -112,6 +112,10 @@ class InputFormatPlugin(Plugin):
|
|||
#: convenience method, :meth:`get_image_collection`.
|
||||
is_image_collection = False
|
||||
|
||||
#: Number of CPU cores used by this plugin
|
||||
#: A value of -1 means that it uses all available cores
|
||||
core_usage = 1
|
||||
|
||||
#: If set to True, the input plugin will perform special processing
|
||||
#: to make its output suitable for viewing
|
||||
for_viewer = False
|
||||
|
|
|
|||
|
|
@ -247,6 +247,7 @@ class ComicInput(InputFormatPlugin):
|
|||
description = 'Optimize comic files (.cbz, .cbr, .cbc) for viewing on portable devices'
|
||||
file_types = set(['cbz', 'cbr', 'cbc'])
|
||||
is_image_collection = True
|
||||
core_usage = -1
|
||||
|
||||
options = set([
|
||||
OptionRecommendation(name='colors', recommended_value=256,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
from calibre.gui2.tools import convert_single_ebook, convert_bulk_ebook
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.customize.ui import plugin_for_input_format
|
||||
|
||||
class ConvertAction(InterfaceAction):
|
||||
|
||||
|
|
@ -115,9 +116,19 @@ def convert_ebook(self, checked, bulk=None):
|
|||
def queue_convert_jobs(self, jobs, changed, bad, rows, previous,
|
||||
converted_func, extra_job_args=[]):
|
||||
for func, args, desc, fmt, id, temp_files in jobs:
|
||||
input_file = args[0]
|
||||
input_fmt = os.path.splitext(input_file)[1]
|
||||
core_usage = 1
|
||||
if input_fmt:
|
||||
input_fmt = input_fmt[1:]
|
||||
plugin = plugin_for_input_format(input_fmt)
|
||||
if plugin is not None:
|
||||
core_usage = plugin.core_usage
|
||||
|
||||
if id not in bad:
|
||||
job = self.gui.job_manager.run_job(Dispatcher(converted_func),
|
||||
func, args=args, description=desc)
|
||||
func, args=args, description=desc,
|
||||
core_usage=core_usage)
|
||||
args = [temp_files, fmt, id]+extra_job_args
|
||||
self.conversion_jobs[job] = tuple(args)
|
||||
|
||||
|
|
|
|||
|
|
@ -198,8 +198,9 @@ def has_jobs(self):
|
|||
return False
|
||||
|
||||
def run_job(self, done, name, args=[], kwargs={},
|
||||
description=''):
|
||||
description='', core_usage=1):
|
||||
job = ParallelJob(name, description, done, args=args, kwargs=kwargs)
|
||||
job.core_usage = core_usage
|
||||
self.add_job(job)
|
||||
self.server.add_job(job)
|
||||
return job
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ def __init__(self, description, done=lambda x: x):
|
|||
self._message = None
|
||||
self._status_text = _('Waiting...')
|
||||
self._done_called = False
|
||||
self.core_usage = 1
|
||||
|
||||
def update(self, consume_notifications=True):
|
||||
if self.duration is not None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue