Fix #1337 (Priority for Conversion Jobs lost)

This commit is contained in:
Kovid Goyal 2008-12-05 13:38:28 -08:00
parent b828f4c245
commit 809b84f539
4 changed files with 42 additions and 2 deletions

View File

@ -6,7 +6,7 @@ from PyQt4.QtGui import QDialog, QMessageBox, QListWidgetItem, QIcon, \
QDesktopServices, QVBoxLayout, QLabel, QPlainTextEdit QDesktopServices, QVBoxLayout, QLabel, QPlainTextEdit
from PyQt4.QtCore import SIGNAL, QTimer, Qt, QSize, QVariant, QUrl from PyQt4.QtCore import SIGNAL, QTimer, Qt, QSize, QVariant, QUrl
from calibre import islinux from calibre.constants import islinux, iswindows
from calibre.gui2.dialogs.config_ui import Ui_Dialog from calibre.gui2.dialogs.config_ui import Ui_Dialog
from calibre.gui2 import qstring_to_unicode, choose_dir, error_dialog, config, \ from calibre.gui2 import qstring_to_unicode, choose_dir, error_dialog, config, \
warning_dialog, ALL_COLUMNS warning_dialog, ALL_COLUMNS
@ -116,6 +116,10 @@ class ConfigDialog(QDialog, Ui_Dialog):
self.systray_icon.setChecked(config['systray_icon']) self.systray_icon.setChecked(config['systray_icon'])
self.sync_news.setChecked(config['upload_news_to_device']) self.sync_news.setChecked(config['upload_news_to_device'])
self.delete_news.setChecked(config['delete_news_from_library_on_upload']) self.delete_news.setChecked(config['delete_news_from_library_on_upload'])
p = {'normal':0, 'high':1, 'low':2}[prefs['worker_process_priority']]
self.priority.setCurrentIndex(p)
self.priority.setVisible(iswindows)
self.priority_label.setVisible(iswindows)
def up_column(self): def up_column(self):
idx = self.columns.currentRow() idx = self.columns.currentRow()
@ -212,6 +216,8 @@ class ConfigDialog(QDialog, Ui_Dialog):
config['confirm_delete'] = bool(self.confirm_delete.isChecked()) config['confirm_delete'] = bool(self.confirm_delete.isChecked())
pattern = self.filename_pattern.commit() pattern = self.filename_pattern.commit()
prefs['filename_pattern'] = pattern prefs['filename_pattern'] = pattern
p = {0:'normal', 1:'high', 2:'low'}[self.priority.currentIndex()]
prefs['worker_process_priority'] = p
prefs['read_file_metadata'] = bool(self.pdf_metadata.isChecked()) prefs['read_file_metadata'] = bool(self.pdf_metadata.isChecked())
config['save_to_disk_single_format'] = BOOK_EXTENSIONS[self.single_format.currentIndex()] config['save_to_disk_single_format'] = BOOK_EXTENSIONS[self.single_format.currentIndex()]
config['cover_flow_queue_length'] = self.cover_browse.value() config['cover_flow_queue_length'] = self.cover_browse.value()

View File

@ -231,6 +231,35 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1" >
<widget class="QComboBox" name="priority" >
<item>
<property name="text" >
<string>Normal</string>
</property>
</item>
<item>
<property name="text" >
<string>High</string>
</property>
</item>
<item>
<property name="text" >
<string>Low</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="priority_label" >
<property name="text" >
<string>Job &amp;priority:</string>
</property>
<property name="buddy" >
<cstring>priority</cstring>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -32,6 +32,7 @@ from math import ceil
from calibre.ptempfile import PersistentTemporaryFile from calibre.ptempfile import PersistentTemporaryFile
from calibre import iswindows, detect_ncpus, isosx from calibre import iswindows, detect_ncpus, isosx
from calibre.utils.config import prefs
DEBUG = False DEBUG = False
@ -223,6 +224,8 @@ class WorkerMother(object):
return child return child
def spawn_free_spirit_windows(self, arg, type='free_spirit'): def spawn_free_spirit_windows(self, arg, type='free_spirit'):
priority = {'high':win32process.HIGH_PRIORITY_CLASS, 'normal':win32process.NORMAL_PRIORITY_CLASS,
'low':win32process.IDLE_PRIORITY_CLASS}[prefs['worker_process_priority']]
fd, name = tempfile.mkstemp('.log', 'calibre_'+type+'_') fd, name = tempfile.mkstemp('.log', 'calibre_'+type+'_')
handle = msvcrt.get_osfhandle(fd) handle = msvcrt.get_osfhandle(fd)
si = win32process.STARTUPINFO() si = win32process.STARTUPINFO()
@ -236,7 +239,7 @@ class WorkerMother(object):
None, # processAttributes None, # processAttributes
None, # threadAttributes None, # threadAttributes
1, # bInheritHandles 1, # bInheritHandles
win32process.CREATE_NO_WINDOW, # Dont want ugly console popping up win32process.CREATE_NO_WINDOW|priority, # Dont want ugly console popping up
self.get_env(), # New environment self.get_env(), # New environment
None, # Current directory None, # Current directory
si si

View File

@ -536,6 +536,8 @@ def _prefs():
help=_('The default output format for ebook conversions.')) help=_('The default output format for ebook conversions.'))
c.add_opt('read_file_metadata', default=True, c.add_opt('read_file_metadata', default=True,
help=_('Read metadata from files')) help=_('Read metadata from files'))
c.add_opt('worker_process_priority', default='normal',
help=_('The priority of worker processes'))
c.add_opt('migrated', default=False, help='For Internal use. Don\'t modify.') c.add_opt('migrated', default=False, help='For Internal use. Don\'t modify.')
return c return c