Refactor automatic cpu detection code to auto_detect_cpus()
This commit is contained in:
@@ -4,8 +4,7 @@ import py
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
def parse_numprocesses(s):
|
def auto_detect_cpus():
|
||||||
if s == 'auto':
|
|
||||||
try:
|
try:
|
||||||
from os import sched_getaffinity
|
from os import sched_getaffinity
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -25,6 +24,11 @@ def parse_numprocesses(s):
|
|||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
return 1
|
return 1
|
||||||
return n if n else 1
|
return n if n else 1
|
||||||
|
|
||||||
|
|
||||||
|
def parse_numprocesses(s):
|
||||||
|
if s == 'auto':
|
||||||
|
return auto_detect_cpus()
|
||||||
else:
|
else:
|
||||||
return int(s)
|
return int(s)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user