mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
ProcessingConfig: added multithread max thread setting, TilesXYZ: max thread now inherrrits from ProcessingConfig
This commit is contained in:
parent
ba17f3b81e
commit
9fd93a1013
@ -50,7 +50,7 @@ from qgis.core import (QgsProcessingException,
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
|
||||
import threading
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from multiprocessing import cpu_count
|
||||
from processing.core.ProcessingConfig import ProcessingConfig
|
||||
|
||||
|
||||
# TMS functions taken from https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/ #spellok
|
||||
@ -235,8 +235,7 @@ class TilesXYZAlgorithmBase(QgisAlgorithm):
|
||||
self.tile_format = self.formats[self.parameterAsEnum(parameters, self.TILE_FORMAT, context)]
|
||||
self.quality = self.parameterAsInt(parameters, self.QUALITY, context)
|
||||
self.metatilesize = self.parameterAsInt(parameters, self.METATILESIZE, context)
|
||||
self.maxThreads = QgsApplication.maxThreads()
|
||||
self.maxThreads = cpu_count() if self.maxThreads == -1 else self.maxThreads # if unbound, maxThreads() returns -1
|
||||
self.maxThreads = int(ProcessingConfig.getSetting(ProcessingConfig.MAX_THREADS))
|
||||
try:
|
||||
self.tile_width = self.parameterAsInt(parameters, self.TILE_WIDTH, context)
|
||||
self.tile_height = self.parameterAsInt(parameters, self.TILE_HEIGHT, context)
|
||||
|
@ -31,6 +31,7 @@ from qgis.core import (NULL,
|
||||
QgsRasterFileWriter)
|
||||
from processing.tools.system import defaultOutputFolder
|
||||
import processing.tools.dataobjects
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
|
||||
class SettingsWatcher(QObject):
|
||||
@ -56,6 +57,7 @@ class ProcessingConfig:
|
||||
WARN_UNMATCHING_CRS = 'WARN_UNMATCHING_CRS'
|
||||
SHOW_PROVIDERS_TOOLTIP = 'SHOW_PROVIDERS_TOOLTIP'
|
||||
SHOW_ALGORITHMS_KNOWN_ISSUES = 'SHOW_ALGORITHMS_KNOWN_ISSUES'
|
||||
MAX_THREADS = 'MAX_THREADS'
|
||||
|
||||
settings = {}
|
||||
settingIcons = {}
|
||||
@ -135,6 +137,14 @@ class ProcessingConfig:
|
||||
valuetype=Setting.SELECTION,
|
||||
options=invalidFeaturesOptions))
|
||||
|
||||
threads = QgsApplication.maxThreads() # if user specified limit for rendering, lets keep that as default here, otherwise max
|
||||
threads = cpu_count() if threads == -1 else threads # if unset, maxThreads() returns -1
|
||||
ProcessingConfig.addSetting(Setting(
|
||||
ProcessingConfig.tr('General'),
|
||||
ProcessingConfig.MAX_THREADS,
|
||||
ProcessingConfig.tr('Max Threads'), threads,
|
||||
valuetype=Setting.INT))
|
||||
|
||||
@staticmethod
|
||||
def setGroupIcon(group, icon):
|
||||
ProcessingConfig.settingIcons[group] = icon
|
||||
|
Loading…
x
Reference in New Issue
Block a user