Ignore:
Timestamp:
16 Nov 2014, 13:21:27 (10 years ago)
Author:
uli
Message:

Reapply psutil deprecation patch from waeup.kofa.

Location:
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba

  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/utils/tests/test_utils.py

    r11949 r11970  
    2929
    3030    def setUp(self):
    31         self.max_pmem = psutil.phymem_usage().total
    3231        self.max_vmem = psutil.virtual_memory().total
    3332        self.max_smem = psutil.swap_memory().total
     
    124123        utils.SYSTEM_MAX_LOAD['virt-mem'] = -(sys.maxint)  # negative int
    125124        assert utils.expensive_actions_allowed() == False
    126 
    127     def test_expensive_actions_allowed_physmem_none(self):
    128         # unset physmem maximum values make KofUtils ignore physmem values
    129         utils = self.get_cleared_util()
    130         utils.SYSTEM_MAX_LOAD['phys-mem'] = None
    131         assert utils.expensive_actions_allowed() == True
    132         # even not-set values won't block us
    133         del utils.SYSTEM_MAX_LOAD['phys-mem']
    134         assert utils.expensive_actions_allowed() == True
    135 
    136     @unittest.skipIf(
    137         psutil.phymem_usage().percent >= 99.99,
    138         reason="System physmem use over 99%. Cannot set higher allowed value.")
    139     def test_expensive_actions_allowed_physmem_ok(self):
    140         # We can react to high physmem values
    141         max_mem = psutil.phymem_usage().total
    142         utils = self.get_cleared_util()
    143         utils.SYSTEM_MAX_LOAD['phys-mem'] = 99.99          # positive float
    144         assert utils.expensive_actions_allowed() == True
    145         utils.SYSTEM_MAX_LOAD['phys-mem'] = -0.01          # negative float
    146         assert utils.expensive_actions_allowed() == True
    147         utils.SYSTEM_MAX_LOAD['phys-mem'] = max_mem        # positive int
    148         assert utils.expensive_actions_allowed() == True
    149         utils.SYSTEM_MAX_LOAD['phys-mem'] = -1             # negative int
    150         assert utils.expensive_actions_allowed() == True
    151 
    152     @unittest.skipIf(
    153         not psutil.phymem_usage().percent,
    154         reason="Can test physmem behavior only if actually using some")
    155     def test_expensive_actions_allowed_physmem_too_much(self):
    156         # We can react if too much physmem is used
    157         max_mem = psutil.phymem_usage().total
    158         utils = self.get_cleared_util()
    159         utils.SYSTEM_MAX_LOAD['phys-mem'] = 0.0            # positive float
    160         assert utils.expensive_actions_allowed() == False
    161         utils.SYSTEM_MAX_LOAD['phys-mem'] = -100.0         # negative float
    162         assert utils.expensive_actions_allowed() == False
    163         utils.SYSTEM_MAX_LOAD['phys-mem'] = 0              # positive int
    164         assert utils.expensive_actions_allowed() == False
    165         utils.SYSTEM_MAX_LOAD['phys-mem'] = -(max_mem)     # negative int
    166         assert utils.expensive_actions_allowed() == False
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/utils/utils.py

    r11952 r11970  
    195195    #: value. `cpu-load`, of course, accepts float values only.
    196196    #: `swap-mem` = Swap Memory, `virt-mem` = Virtual Memory,
    197     #: `phys-mem` = Physical Memory, `cpu-load` = CPU load in percent.
     197    #: `cpu-load` = CPU load in percent.
    198198    SYSTEM_MAX_LOAD = {
    199199        'swap-mem': None,
    200200        'virt-mem': None,
    201         'phys-mem': None,
    202201        'cpu-load': 100.0,
    203202        }
     
    317316            ('swap-mem', psutil.swap_memory),
    318317            ('virt-mem', psutil.virtual_memory),
    319             ('phys-mem', psutil.phymem_usage),
    320318            ):
    321319            max_val = max_values.get(key, None)
Note: See TracChangeset for help on using the changeset viewer.