mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
OSX and Linux: Add a setting in Preferences->Behavior to control the priority with which calibre worker processes run. Fixes #741231 (calibre-parallel process priority)
This commit is contained in:
parent
90a53c6dcf
commit
468ac27782
@ -31,9 +31,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
db = gui.library_view.model().db
|
db = gui.library_view.model().db
|
||||||
|
|
||||||
r = self.register
|
r = self.register
|
||||||
|
choices = [(_('Low'), 'low'), (_('Normal'), 'normal'), (_('High'),
|
||||||
r('worker_process_priority', prefs, choices=
|
'high')] if iswindows else \
|
||||||
[(_('Low'), 'low'), (_('Normal'), 'normal'), (_('High'), 'high')])
|
[(_('Normal'), 'normal'), (_('Low'), 'low'), (_('Very low'),
|
||||||
|
'high')]
|
||||||
|
r('worker_process_priority', prefs, choices=choices)
|
||||||
|
|
||||||
r('network_timeout', prefs)
|
r('network_timeout', prefs)
|
||||||
|
|
||||||
@ -60,9 +62,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
signal = getattr(self.opt_internally_viewed_formats, 'item'+signal)
|
signal = getattr(self.opt_internally_viewed_formats, 'item'+signal)
|
||||||
signal.connect(self.internally_viewed_formats_changed)
|
signal.connect(self.internally_viewed_formats_changed)
|
||||||
|
|
||||||
self.settings['worker_process_priority'].gui_obj.setVisible(iswindows)
|
|
||||||
self.priority_label.setVisible(iswindows)
|
|
||||||
|
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
ConfigWidgetBase.initialize(self)
|
ConfigWidgetBase.initialize(self)
|
||||||
|
@ -7,6 +7,7 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import subprocess, os, sys, time, binascii, cPickle
|
import subprocess, os, sys, time, binascii, cPickle
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from calibre.constants import iswindows, isosx, isfrozen
|
from calibre.constants import iswindows, isosx, isfrozen
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
@ -19,6 +20,12 @@ if iswindows:
|
|||||||
except:
|
except:
|
||||||
raise RuntimeError('NUL %r file missing in windows'%os.devnull)
|
raise RuntimeError('NUL %r file missing in windows'%os.devnull)
|
||||||
|
|
||||||
|
def renice(niceness):
|
||||||
|
try:
|
||||||
|
os.nice(niceness)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
class Worker(object):
|
class Worker(object):
|
||||||
'''
|
'''
|
||||||
Platform independent object for launching child processes. All processes
|
Platform independent object for launching child processes. All processes
|
||||||
@ -144,6 +151,13 @@ class Worker(object):
|
|||||||
'normal' : win32process.NORMAL_PRIORITY_CLASS,
|
'normal' : win32process.NORMAL_PRIORITY_CLASS,
|
||||||
'low' : win32process.IDLE_PRIORITY_CLASS}[priority]
|
'low' : win32process.IDLE_PRIORITY_CLASS}[priority]
|
||||||
args['creationflags'] = win32process.CREATE_NO_WINDOW|priority
|
args['creationflags'] = win32process.CREATE_NO_WINDOW|priority
|
||||||
|
else:
|
||||||
|
niceness = {
|
||||||
|
'normal' : 0,
|
||||||
|
'low' : 10,
|
||||||
|
'high' : 20,
|
||||||
|
}[priority]
|
||||||
|
args['preexec_fn'] = partial(renice, niceness)
|
||||||
ret = None
|
ret = None
|
||||||
if redirect_output:
|
if redirect_output:
|
||||||
self._file = PersistentTemporaryFile('_worker_redirect.log')
|
self._file = PersistentTemporaryFile('_worker_redirect.log')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user