]> granicus.if.org Git - python/commitdiff
Allow "-j0" as an argument to regrtest, to automatically select an
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 23 Mar 2011 19:17:45 +0000 (20:17 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 23 Mar 2011 19:17:45 +0000 (20:17 +0100)
appropriate number of parallel workers.

Lib/test/regrtest.py

index 1e72f800b9d995d4c2309638e5c075ad52114d2e..a00f15aae4b92de2d634498ca31d6c4994fee53b 100755 (executable)
@@ -374,6 +374,13 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
             forever = True
         elif o in ('-j', '--multiprocess'):
             use_mp = int(a)
+            if use_mp <= 0:
+                try:
+                    import multiprocessing
+                    # Use all cores + extras for tests that like to sleep
+                    use_mp = 2 + multiprocessing.cpu_count()
+                except (ImportError, NotImplementedError):
+                    use_mp = 3
         elif o == '--header':
             header = True
         elif o == '--slaveargs':