mirror of
https://github.com/ciromattia/kcc
synced 2026-10-08 18:42:31 +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:
|
### 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.
|
- 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.
|
- [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)
|
- **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
|
## USAGE
|
||||||
|
|||||||
+11
-3
@@ -32,6 +32,7 @@ import comic2ebook
|
|||||||
import kindlesplit
|
import kindlesplit
|
||||||
import socket
|
import socket
|
||||||
import string
|
import string
|
||||||
|
from psutil import virtual_memory
|
||||||
from KCC_rc_web import WebContent
|
from KCC_rc_web import WebContent
|
||||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||||
from SocketServer import ThreadingMixIn
|
from SocketServer import ThreadingMixIn
|
||||||
@@ -265,11 +266,17 @@ class WorkerThread(QtCore.QThread):
|
|||||||
self.errors = False
|
self.errors = False
|
||||||
self.kindlegenErrorCode = [0]
|
self.kindlegenErrorCode = [0]
|
||||||
self.workerOutput = []
|
self.workerOutput = []
|
||||||
# 4 should be safe value. It will not melt 32bit enviroments and machines with pathologically low amount of RAM.
|
# Let's make sure that we don't fill the memory
|
||||||
if QtCore.QThread.idealThreadCount() < 4:
|
availableMemory = virtual_memory()[0]/1000000000
|
||||||
self.threadNumber = QtCore.QThread.idealThreadCount()
|
if availableMemory <= 2:
|
||||||
|
self.threadNumber = 1
|
||||||
|
elif 2 < availableMemory <= 4:
|
||||||
|
self.threadNumber = 2
|
||||||
else:
|
else:
|
||||||
self.threadNumber = 4
|
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):
|
def __del__(self):
|
||||||
self.wait()
|
self.wait()
|
||||||
@@ -380,6 +387,7 @@ class WorkerThread(QtCore.QThread):
|
|||||||
self.emit(QtCore.SIGNAL("progressBarTick"))
|
self.emit(QtCore.SIGNAL("progressBarTick"))
|
||||||
self.emit(QtCore.SIGNAL("addMessage"), 'Creating MOBI file...', 'info')
|
self.emit(QtCore.SIGNAL("addMessage"), 'Creating MOBI file...', 'info')
|
||||||
self.workerOutput = []
|
self.workerOutput = []
|
||||||
|
# Number of KindleGen threads depends on the size of RAM
|
||||||
self.pool.setMaxThreadCount(self.threadNumber)
|
self.pool.setMaxThreadCount(self.threadNumber)
|
||||||
for item in outputPath:
|
for item in outputPath:
|
||||||
worker = KindleGenThread(item)
|
worker = KindleGenThread(item)
|
||||||
|
|||||||
Reference in New Issue
Block a user