##// END OF EJS Templates
worker: count the number of CPUs...
Bryan O'Sullivan -
r18635:fed06dd0 default
parent child Browse files
Show More
@@ -0,0 +1,29 b''
1 # worker.py - master-slave parallelism support
2 #
3 # Copyright 2013 Facebook, Inc.
4 #
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
7
8 import os
9
10 def countcpus():
11 '''try to count the number of CPUs on the system'''
12
13 # posix
14 try:
15 n = int(os.sysconf('SC_NPROCESSORS_ONLN'))
16 if n > 0:
17 return n
18 except (AttributeError, ValueError):
19 pass
20
21 # windows
22 try:
23 n = int(os.environ['NUMBER_OF_PROCESSORS'])
24 if n > 0:
25 return n
26 except (KeyError, ValueError):
27 pass
28
29 return 1
General Comments 0
You need to be logged in to leave comments. Login now