mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 13:11:19 -03:30
Merge pull request #156 from swills/portable-get_system_task_capacity
Make get_system_task_capacity portable
This commit is contained in:
commit
ca094f0e86
@ -17,6 +17,7 @@ import threading
|
||||
import contextlib
|
||||
import tempfile
|
||||
import six
|
||||
import psutil
|
||||
|
||||
# Decorator
|
||||
from decorator import decorator
|
||||
@ -581,15 +582,11 @@ def get_system_task_capacity():
|
||||
from django.conf import settings
|
||||
if hasattr(settings, 'SYSTEM_TASK_CAPACITY'):
|
||||
return settings.SYSTEM_TASK_CAPACITY
|
||||
try:
|
||||
out = subprocess.check_output(['free', '-m'])
|
||||
except subprocess.CalledProcessError:
|
||||
logger.exception('Problem obtaining capacity from system.')
|
||||
return 0
|
||||
total_mem_value = out.split()[7]
|
||||
if int(total_mem_value) <= 2048:
|
||||
mem = psutil.virtual_memory()
|
||||
total_mem_value = mem.total / 1024 / 1024
|
||||
if total_mem_value <= 2048:
|
||||
return 50
|
||||
return 50 + ((int(total_mem_value) / 1024) - 2) * 75
|
||||
return 50 + ((total_mem_value / 1024) - 2) * 75
|
||||
|
||||
|
||||
_inventory_updates = threading.local()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user