mirror of
https://github.com/ciromattia/kcc
synced 2026-01-28 07:57:41 +00:00
Number of KindleGen threads is now dynamic
This commit is contained in:
@@ -38,8 +38,9 @@ You can find the latest released binary at the following links:
|
||||
|
||||
### For compiling/running from source:
|
||||
- Python 2.7 - Included in MacOS and Linux, follow the [official documentation](http://www.python.org/getit/windows/) to install on Windows.
|
||||
- PyQt4 - Please refer to official documentation for installing into your system.
|
||||
- [PyQt4](http://www.riverbankcomputing.co.uk/software/pyqt/download) - Please refer to official documentation for installing into your system.
|
||||
- [Pillow](http://pypi.python.org/pypi/Pillow/) 2.2.1+ - For comic optimizations. Please refer to official documentation for installing into your system.
|
||||
- [Psutil](https://code.google.com/p/psutil/) - Please refer to official documentation for installing into your system.
|
||||
- **To build OS X release a modified QT is required:** [Patch](https://github.com/ciromattia/kcc/blob/master/other/QT-4.8.5-QListWidget.patch)
|
||||
|
||||
## USAGE
|
||||
|
||||
@@ -32,6 +32,7 @@ import comic2ebook
|
||||
import kindlesplit
|
||||
import socket
|
||||
import string
|
||||
from psutil import virtual_memory
|
||||
from KCC_rc_web import WebContent
|
||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||
from SocketServer import ThreadingMixIn
|
||||
@@ -265,11 +266,17 @@ class WorkerThread(QtCore.QThread):
|
||||
self.errors = False
|
||||
self.kindlegenErrorCode = [0]
|
||||
self.workerOutput = []
|
||||
# 4 should be safe value. It will not melt 32bit enviroments and machines with pathologically low amount of RAM.
|
||||
if QtCore.QThread.idealThreadCount() < 4:
|
||||
self.threadNumber = QtCore.QThread.idealThreadCount()
|
||||
# Let's make sure that we don't fill the memory
|
||||
availableMemory = virtual_memory()[0]/1000000000
|
||||
if availableMemory <= 2:
|
||||
self.threadNumber = 1
|
||||
elif 2 < availableMemory <= 4:
|
||||
self.threadNumber = 2
|
||||
else:
|
||||
self.threadNumber = 4
|
||||
# Let's make sure that we don't use too many threads
|
||||
if self.threadNumber > QtCore.QThread.idealThreadCount():
|
||||
self.threadNumber = QtCore.QThread.idealThreadCount()
|
||||
|
||||
def __del__(self):
|
||||
self.wait()
|
||||
@@ -380,6 +387,7 @@ class WorkerThread(QtCore.QThread):
|
||||
self.emit(QtCore.SIGNAL("progressBarTick"))
|
||||
self.emit(QtCore.SIGNAL("addMessage"), 'Creating MOBI file...', 'info')
|
||||
self.workerOutput = []
|
||||
# Number of KindleGen threads depends on the size of RAM
|
||||
self.pool.setMaxThreadCount(self.threadNumber)
|
||||
for item in outputPath:
|
||||
worker = KindleGenThread(item)
|
||||
|
||||
Reference in New Issue
Block a user