Show More
@@ -8,7 +8,6 b'' | |||||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
10 | import errno |
|
10 | import errno | |
11 | import multiprocessing |
|
|||
12 | import os |
|
11 | import os | |
13 | import signal |
|
12 | import signal | |
14 | import sys |
|
13 | import sys | |
@@ -19,10 +18,24 b' from . import util' | |||||
19 |
|
18 | |||
20 | def countcpus(): |
|
19 | def countcpus(): | |
21 | '''try to count the number of CPUs on the system''' |
|
20 | '''try to count the number of CPUs on the system''' | |
|
21 | ||||
|
22 | # posix | |||
22 | try: |
|
23 | try: | |
23 | return multiprocessing.cpu_count() |
|
24 | n = int(os.sysconf('SC_NPROCESSORS_ONLN')) | |
24 | except NotImplementedError: |
|
25 | if n > 0: | |
25 |
return |
|
26 | return n | |
|
27 | except (AttributeError, ValueError): | |||
|
28 | pass | |||
|
29 | ||||
|
30 | # windows | |||
|
31 | try: | |||
|
32 | n = int(os.environ['NUMBER_OF_PROCESSORS']) | |||
|
33 | if n > 0: | |||
|
34 | return n | |||
|
35 | except (KeyError, ValueError): | |||
|
36 | pass | |||
|
37 | ||||
|
38 | return 1 | |||
26 |
|
39 | |||
27 | def _numworkers(ui): |
|
40 | def _numworkers(ui): | |
28 | s = ui.config('worker', 'numcpus') |
|
41 | s = ui.config('worker', 'numcpus') |
General Comments 0
You need to be logged in to leave comments.
Login now