mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04: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
@ -112,6 +112,10 @@ class InputFormatPlugin(Plugin):
|
|||||||
#: convenience method, :meth:`get_image_collection`.
|
#: convenience method, :meth:`get_image_collection`.
|
||||||
is_image_collection = False
|
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
|
#: If set to True, the input plugin will perform special processing
|
||||||
#: to make its output suitable for viewing
|
#: to make its output suitable for viewing
|
||||||
for_viewer = False
|
for_viewer = False
|
||||||
|
@ -247,6 +247,7 @@ class ComicInput(InputFormatPlugin):
|
|||||||
description = 'Optimize comic files (.cbz, .cbr, .cbc) for viewing on portable devices'
|
description = 'Optimize comic files (.cbz, .cbr, .cbc) for viewing on portable devices'
|
||||||
file_types = set(['cbz', 'cbr', 'cbc'])
|
file_types = set(['cbz', 'cbr', 'cbc'])
|
||||||
is_image_collection = True
|
is_image_collection = True
|
||||||
|
core_usage = -1
|
||||||
|
|
||||||
options = set([
|
options = set([
|
||||||
OptionRecommendation(name='colors', recommended_value=256,
|
OptionRecommendation(name='colors', recommended_value=256,
|
||||||
|
@ -14,6 +14,7 @@ from calibre.gui2 import error_dialog, Dispatcher
|
|||||||
from calibre.gui2.tools import convert_single_ebook, convert_bulk_ebook
|
from calibre.gui2.tools import convert_single_ebook, convert_bulk_ebook
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
from calibre.customize.ui import plugin_for_input_format
|
||||||
|
|
||||||
class ConvertAction(InterfaceAction):
|
class ConvertAction(InterfaceAction):
|
||||||
|
|
||||||
@ -115,9 +116,19 @@ class ConvertAction(InterfaceAction):
|
|||||||
def queue_convert_jobs(self, jobs, changed, bad, rows, previous,
|
def queue_convert_jobs(self, jobs, changed, bad, rows, previous,
|
||||||
converted_func, extra_job_args=[]):
|
converted_func, extra_job_args=[]):
|
||||||
for func, args, desc, fmt, id, temp_files in jobs:
|
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:
|
if id not in bad:
|
||||||
job = self.gui.job_manager.run_job(Dispatcher(converted_func),
|
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
|
args = [temp_files, fmt, id]+extra_job_args
|
||||||
self.conversion_jobs[job] = tuple(args)
|
self.conversion_jobs[job] = tuple(args)
|
||||||
|
|
||||||
|
@ -198,8 +198,9 @@ class JobManager(QAbstractTableModel):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def run_job(self, done, name, args=[], kwargs={},
|
def run_job(self, done, name, args=[], kwargs={},
|
||||||
description=''):
|
description='', core_usage=1):
|
||||||
job = ParallelJob(name, description, done, args=args, kwargs=kwargs)
|
job = ParallelJob(name, description, done, args=args, kwargs=kwargs)
|
||||||
|
job.core_usage = core_usage
|
||||||
self.add_job(job)
|
self.add_job(job)
|
||||||
self.server.add_job(job)
|
self.server.add_job(job)
|
||||||
return job
|
return job
|
||||||
|
@ -42,6 +42,7 @@ class BaseJob(object):
|
|||||||
self._message = None
|
self._message = None
|
||||||
self._status_text = _('Waiting...')
|
self._status_text = _('Waiting...')
|
||||||
self._done_called = False
|
self._done_called = False
|
||||||
|
self.core_usage = 1
|
||||||
|
|
||||||
def update(self, consume_notifications=True):
|
def update(self, consume_notifications=True):
|
||||||
if self.duration is not None:
|
if self.duration is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user