#56 fakes setting cpu_affinity on unsupported platforms

This commit is contained in:
Ilan Steemers
2015-09-09 13:25:27 +02:00
parent 0e03601572
commit cc178df2b1
4 changed files with 9 additions and 3 deletions
+6 -1
View File
@@ -431,7 +431,7 @@ def scheduler(broker=None):
# get args, kwargs and hook
if s.kwargs:
try:
# eval should be safe here cause dict()
# eval should be safe here because dict()
kwargs = eval('dict({})'.format(s.kwargs))
except SyntaxError:
kwargs = {}
@@ -499,7 +499,12 @@ def set_cpu_affinity(n, process_ids, actual=not Conf.TESTING):
"""
# check if we have the psutil module
if not psutil:
logger.warning('Skipping cpu affinity because psutil was not found.')
return
# check if the platform supports cpu_affinity
if actual and not hasattr(psutil.Process(process_ids[0]), 'cpu_affinity'):
logger.warning('Faking cpu affinity because it is not supported on this platform')
actual = False
# get the available processors
cpu_list = list(range(psutil.cpu_count()))
# affinities of 0 or gte cpu_count, equals to no affinity
-1
View File
@@ -117,6 +117,5 @@ CACHES = {
# Django Q specific
Q_CLUSTER = {'name': 'django_q_test',
'cpu_affinity': 1,
'testing': True,
'log_level': 'DEBUG',
'django_redis': 'default'}