Handle CPU detection errors and running on Travis

This commit is contained in:
Chris Kuehl
2018-10-20 17:13:57 -07:00
committed by Chris Kuehl
parent ba5e27e4ec
commit ec0ed8aef5
2 changed files with 34 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import unicode_literals
import multiprocessing
import os
import shlex
from pre_commit.util import cmd_output
@@ -52,5 +53,11 @@ def target_concurrency(hook):
if hook['require_serial']:
return 1
else:
# TODO: something smart!
return multiprocessing.cpu_count()
# Travis appears to have a bunch of CPUs, but we can't use them all.
if 'TRAVIS' in os.environ:
return 2
else:
try:
return multiprocessing.cpu_count()
except NotImplementedError:
return 1