[GRASS-SVN] r58402 - grass/trunk/gui/wxpython/animation

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 6 10:59:59 PST 2013


Author: annakrat
Date: 2013-12-06 10:59:59 -0800 (Fri, 06 Dec 2013)
New Revision: 58402

Modified:
   grass/trunk/gui/wxpython/animation/controller.py
   grass/trunk/gui/wxpython/animation/utils.py
Log:
wxGUI/animation: autodetect number of CPUs

Modified: grass/trunk/gui/wxpython/animation/controller.py
===================================================================
--- grass/trunk/gui/wxpython/animation/controller.py	2013-12-06 16:41:39 UTC (rev 58401)
+++ grass/trunk/gui/wxpython/animation/controller.py	2013-12-06 18:59:59 UTC (rev 58402)
@@ -23,7 +23,7 @@
 from animation.temporal_manager import TemporalManager
 from animation.dialogs import InputDialog, EditDialog, ExportDialog
 from animation.utils import TemporalMode, Orientation, RenderText, WxImageToPil, \
-    sampleCmdMatrixAndCreateNames, layerListToCmdsMatrix, HashCmds
+    sampleCmdMatrixAndCreateNames, layerListToCmdsMatrix, HashCmds, getCpuCount
 from animation.data import AnimationData
 
 
@@ -354,7 +354,7 @@
             else:
                 self._load3DData(animData)
             self._loadLegend(animData)
-        self.bitmapProvider.Load(nprocs=4)
+        self.bitmapProvider.Load(nprocs=getCpuCount())
         # clear pools
         self.bitmapPool.Clear()
         self.mapFilesPool.Clear()
@@ -429,7 +429,7 @@
     def Reload(self):
         self.EndAnimation()
 
-        self.bitmapProvider.Load(force=True)
+        self.bitmapProvider.Load(nprocs=getCpuCount(), force=True)
 
         self.EndAnimation()
 

Modified: grass/trunk/gui/wxpython/animation/utils.py
===================================================================
--- grass/trunk/gui/wxpython/animation/utils.py	2013-12-06 16:41:39 UTC (rev 58401)
+++ grass/trunk/gui/wxpython/animation/utils.py	2013-12-06 18:59:59 UTC (rev 58402)
@@ -20,6 +20,7 @@
 import os
 import wx
 import hashlib
+from multiprocessing import cpu_count
 try:
     from PIL import Image
     hasPIL = True
@@ -309,3 +310,13 @@
             namesList.append(None)
     assert(j == len(cmdMatrix) - 1)
     return namesList
+
+
+def getCpuCount():
+    """!Returns number of available cpus.
+    If fails, default (4) is returned.
+    """
+    try:
+        return cpu_count()
+    except NotImplementedError:
+        return 4



More information about the grass-commit mailing list