mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 13:00:10 -06:00
Handle CPU detection errors and running on Travis
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user