[Python-apps-commits] r5770 - in packages/pyrit/trunk/debian (3 files)

chrisk-guest at users.alioth.debian.org chrisk-guest at users.alioth.debian.org
Tue Jul 6 19:42:10 UTC 2010


    Date: Tuesday, July 6, 2010 @ 19:41:59
  Author: chrisk-guest
Revision: 5770

Add patch to support limiting the number of CPU cores used

Added:
  packages/pyrit/trunk/debian/patches/0007-add-option-to-limit-cores.patch
Modified:
  packages/pyrit/trunk/debian/changelog
  packages/pyrit/trunk/debian/patches/series

Modified: packages/pyrit/trunk/debian/changelog
===================================================================
--- packages/pyrit/trunk/debian/changelog	2010-07-06 19:39:26 UTC (rev 5769)
+++ packages/pyrit/trunk/debian/changelog	2010-07-06 19:41:59 UTC (rev 5770)
@@ -8,5 +8,6 @@
     - 0004-Fixed-deprecation-warning-generated-by-sql-alchemy
     - 0005-Link-against-libcrypto-not-libssl
     - 0006-custom-config-file
+    - 0007-add-option-to-limit-cores
 
  -- Christian Kastner <debian at kvr.at>  Thu, 20 May 2010 14:43:26 +0200

Added: packages/pyrit/trunk/debian/patches/0007-add-option-to-limit-cores.patch
===================================================================
--- packages/pyrit/trunk/debian/patches/0007-add-option-to-limit-cores.patch	                        (rev 0)
+++ packages/pyrit/trunk/debian/patches/0007-add-option-to-limit-cores.patch	2010-07-06 19:41:59 UTC (rev 5770)
@@ -0,0 +1,61 @@
+From: Christian Kastner <debian at kvr.at>
+Date: Tue, 6 Jul 2010 21:28:47 +0200
+Subject: [PATCH] Add option to limit number of cores used
+
+This patch adds a configuration option which allows one to limit the number of
+cores Pyrit will use. This only affects non-GPU processors.
+
+This patch is Debian-specific.
+
+Forwarded: no
+Last-Update: 2010-07-06
+Index: pyrit-0.3.0/cpyrit/config.py
+===================================================================
+--- pyrit-0.3.0.orig/cpyrit/config.py	2010-07-06 21:29:17.637835162 +0200
++++ pyrit-0.3.0/cpyrit/config.py	2010-07-06 21:29:33.133837906 +0200
+@@ -28,7 +28,8 @@
+               'rpc_server': 'true', \
+               'rpc_announce': 'true', \
+               'rpc_announce_broadcast': 'false', \
+-              'rpc_knownclients': ''}
++              'rpc_knownclients': '',
++              'limit_ncpus': 0}
+     return config
+ 
+ 
+Index: pyrit-0.3.0/cpyrit/util.py
+===================================================================
+--- pyrit-0.3.0.orig/cpyrit/util.py	2010-07-06 21:29:17.701834961 +0200
++++ pyrit-0.3.0/cpyrit/util.py	2010-07-06 21:29:33.133837906 +0200
+@@ -49,6 +49,7 @@
+ from _cpyrit_cpu import VERSION, grouper
+ import cpyrit
+ import storage
++import config
+ 
+ 
+ def _detect_ncpus():
+@@ -72,7 +73,22 @@
+     #return the default value
+     return 1
+ 
+-ncpus = _detect_ncpus()
++def _limit_ncpus():
++    """Limit the number of reported CPUs if so requested"""
++    detected_ncpus = _detect_ncpus()
++    try:
++        limited_ncpus = int(config.cfg['limit_ncpus'])
++    except ValueError:
++        raise ValueError("Invalid 'limit_ncpus' in configuration")
++
++    if limited_ncpus < 0:
++        raise ValueError("Invalid 'limit_ncpus' in configuration")
++    if limited_ncpus > 0 and limited_ncpus < detected_ncpus:
++        return limited_ncpus
++    return detected_ncpus
++        
++
++ncpus = _limit_ncpus()
+ """ Number of effective CPUs (in the moment the module was loaded)."""
+ 
+ 

Modified: packages/pyrit/trunk/debian/patches/series
===================================================================
--- packages/pyrit/trunk/debian/patches/series	2010-07-06 19:39:26 UTC (rev 5769)
+++ packages/pyrit/trunk/debian/patches/series	2010-07-06 19:41:59 UTC (rev 5770)
@@ -4,3 +4,4 @@
 0004-Fixed-deprecation-warning-generated-by-sql-alchemy.patch
 0005-Link-against-libcrypto-not-libssl.patch
 0006-custom-config-file.patch
+0007-add-option-to-limit-cores.patch




More information about the Python-apps-commits mailing list