Skip to content

Commit

Permalink
Added a try/except around a call to multiprocessing.cpu_count()
Browse files Browse the repository at this point in the history
In some situations, the multiprocessing.cpu_count() function can raise
NotImplementedError. I.e. this can happen on Windows if the environment
will lack the 'NUMBER_OF_PROCESSORS' variable, or this variable will
contain a non-numeric character.

If this exception will occur, the worker will use a substitution value
of 1 CPU.
  • Loading branch information
antekone committed Jan 17, 2017
1 parent 1f5865a commit 0344a0d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion worker/buildbot_worker/base.py
Expand Up @@ -315,7 +315,10 @@ def remote_getWorkerInfo(self):
if os.path.isfile(filename):
files[f] = open(filename, "r").read()
if not self.numcpus:
self.numcpus = multiprocessing.cpu_count()
try:
self.numcpus = multiprocessing.cpu_count()
except NotImplementedError:
self.numcpus = 1
files['environ'] = os.environ.copy()
files['system'] = os.name
files['basedir'] = self.basedir
Expand Down

0 comments on commit 0344a0d

Please sign in to comment.