mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add an option in Preferences->Miscellaneous to abort conversion jobs that take too long. Fixes #835233 ([Enhancement] Conversion timeout)
This commit is contained in:
parent
2ee7653427
commit
588bfefce8
@ -99,6 +99,7 @@ gprefs.defaults['book_display_fields'] = [
|
||||
gprefs.defaults['default_author_link'] = 'http://en.wikipedia.org/w/index.php?search={author}'
|
||||
gprefs.defaults['preserve_date_on_ctl'] = True
|
||||
gprefs.defaults['cb_fullscreen'] = False
|
||||
gprefs.defaults['worker_max_time'] = 0
|
||||
|
||||
# }}}
|
||||
|
||||
|
@ -181,6 +181,20 @@ class JobManager(QAbstractTableModel): # {{{
|
||||
self.dataChanged.emit(
|
||||
self.index(idx, 0), self.index(idx, 3))
|
||||
|
||||
# Kill parallel jobs that have gone on too long
|
||||
try:
|
||||
wmax_time = gprefs['worker_max_time'] * 60
|
||||
except:
|
||||
wmax_time = 0
|
||||
|
||||
if wmax_time > 0:
|
||||
for job in self.jobs:
|
||||
if isinstance(job, ParallelJob):
|
||||
rtime = job.running_time
|
||||
if (rtime is not None and rtime > wmax_time and
|
||||
job.duration is None):
|
||||
job.timed_out = True
|
||||
self.server.kill_job(job)
|
||||
|
||||
def _add_job(self, job):
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
@ -8,7 +8,8 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, Setting
|
||||
from calibre.gui2.preferences.misc_ui import Ui_Form
|
||||
from calibre.gui2 import error_dialog, config, open_local_file, info_dialog
|
||||
from calibre.gui2 import (error_dialog, config, open_local_file, info_dialog,
|
||||
gprefs)
|
||||
from calibre.constants import isosx
|
||||
from calibre import get_proxies
|
||||
|
||||
@ -29,6 +30,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
r = self.register
|
||||
r('worker_limit', config, restart_required=True, setting=WorkersSetting)
|
||||
r('enforce_cpu_limit', config, restart_required=True)
|
||||
r('worker_max_time', gprefs)
|
||||
self.device_detection_button.clicked.connect(self.debug_device_detection)
|
||||
self.button_open_config_dir.clicked.connect(self.open_config_dir)
|
||||
self.user_defined_device_button.clicked.connect(self.user_defined_device)
|
||||
|
@ -51,21 +51,21 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="device_detection_button">
|
||||
<property name="text">
|
||||
<string>Debug &device detection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="user_defined_device_button">
|
||||
<property name="text">
|
||||
<string>Get information to setup the &user defined device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -78,7 +78,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<spacer name="verticalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -91,14 +91,14 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="button_open_config_dir">
|
||||
<property name="text">
|
||||
<string>Open calibre &configuration directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="9" column="0">
|
||||
<spacer name="verticalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -111,14 +111,14 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<item row="10" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="button_osx_symlinks">
|
||||
<property name="text">
|
||||
<string>&Install command line tools</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="21" column="0">
|
||||
<item row="22" column="0">
|
||||
<spacer name="verticalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -131,13 +131,39 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<item row="11" column="0" colspan="2">
|
||||
<widget class="QLabel" name="proxies">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>&Abort conversion jobs that take more than:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_worker_max_time</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="opt_worker_max_time">
|
||||
<property name="specialValueText">
|
||||
<string>Never abort</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> minutes</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -43,13 +43,17 @@ class BaseJob(object):
|
||||
self._status_text = _('Waiting...')
|
||||
self._done_called = False
|
||||
self.core_usage = 1
|
||||
self.timed_out = False
|
||||
|
||||
def update(self, consume_notifications=True):
|
||||
if self.duration is not None:
|
||||
self._run_state = self.FINISHED
|
||||
self.percent = 100
|
||||
if self.killed:
|
||||
self._status_text = _('Stopped')
|
||||
if self.timed_out:
|
||||
self._status_text = _('Aborted, taking too long')
|
||||
else:
|
||||
self._status_text = _('Stopped')
|
||||
else:
|
||||
self._status_text = _('Error') if self.failed else _('Finished')
|
||||
if DEBUG:
|
||||
|
Loading…
x
Reference in New Issue
Block a user