当前位置: 首页>>代码示例>>Python>>正文


Python psutil.IOPRIO_CLASS_IDLE属性代码示例

本文整理汇总了Python中psutil.IOPRIO_CLASS_IDLE属性的典型用法代码示例。如果您正苦于以下问题:Python psutil.IOPRIO_CLASS_IDLE属性的具体用法?Python psutil.IOPRIO_CLASS_IDLE怎么用?Python psutil.IOPRIO_CLASS_IDLE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在psutil的用法示例。


在下文中一共展示了psutil.IOPRIO_CLASS_IDLE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ionice_errs

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import IOPRIO_CLASS_IDLE [as 别名]
def test_ionice_errs(self):
        sproc = get_test_subprocess()
        p = psutil.Process(sproc.pid)
        if LINUX:
            self.assertRaises(ValueError, p.ionice, 2, 10)
            self.assertRaises(ValueError, p.ionice, 2, -1)
            self.assertRaises(ValueError, p.ionice, 4)
            self.assertRaises(TypeError, p.ionice, 2, "foo")
            self.assertRaisesRegex(
                ValueError, "can't specify value with IOPRIO_CLASS_NONE",
                p.ionice, psutil.IOPRIO_CLASS_NONE, 1)
            self.assertRaisesRegex(
                ValueError, "can't specify value with IOPRIO_CLASS_IDLE",
                p.ionice, psutil.IOPRIO_CLASS_IDLE, 1)
            self.assertRaisesRegex(
                ValueError, "'ioclass' argument must be specified",
                p.ionice, value=1)
        else:
            self.assertRaises(ValueError, p.ionice, 3)
            self.assertRaises(TypeError, p.ionice, 2, 1) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:22,代码来源:test_process.py

示例2: _makeNice

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import IOPRIO_CLASS_IDLE [as 别名]
def _makeNice(process):
    try:
        ps = psutil.Process(process.pid)
        ps.ionice(psutil.IOPRIO_CLASS_IDLE)
    except AttributeError:
        logger.debug("ionice is not available") 
开发者ID:AmesCornish,项目名称:buttersink,代码行数:8,代码来源:Butter.py

示例3: test_ionice_linux

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import IOPRIO_CLASS_IDLE [as 别名]
def test_ionice_linux(self):
        p = psutil.Process()
        if not CI_TESTING:
            self.assertEqual(p.ionice()[0], psutil.IOPRIO_CLASS_NONE)
        self.assertEqual(psutil.IOPRIO_CLASS_NONE, 0)
        self.assertEqual(psutil.IOPRIO_CLASS_RT, 1)  # high
        self.assertEqual(psutil.IOPRIO_CLASS_BE, 2)  # normal
        self.assertEqual(psutil.IOPRIO_CLASS_IDLE, 3)  # low
        init = p.ionice()
        try:
            # low
            p.ionice(psutil.IOPRIO_CLASS_IDLE)
            self.assertEqual(tuple(p.ionice()), (psutil.IOPRIO_CLASS_IDLE, 0))
            with self.assertRaises(ValueError):  # accepts no value
                p.ionice(psutil.IOPRIO_CLASS_IDLE, value=7)
            # normal
            p.ionice(psutil.IOPRIO_CLASS_BE)
            self.assertEqual(tuple(p.ionice()), (psutil.IOPRIO_CLASS_BE, 0))
            p.ionice(psutil.IOPRIO_CLASS_BE, value=7)
            self.assertEqual(tuple(p.ionice()), (psutil.IOPRIO_CLASS_BE, 7))
            with self.assertRaises(ValueError):
                p.ionice(psutil.IOPRIO_CLASS_BE, value=8)
            try:
                p.ionice(psutil.IOPRIO_CLASS_RT, value=7)
            except psutil.AccessDenied:
                pass
            # errs
            self.assertRaisesRegex(
                ValueError, "ioclass accepts no value",
                p.ionice, psutil.IOPRIO_CLASS_NONE, 1)
            self.assertRaisesRegex(
                ValueError, "ioclass accepts no value",
                p.ionice, psutil.IOPRIO_CLASS_IDLE, 1)
            self.assertRaisesRegex(
                ValueError, "'ioclass' argument must be specified",
                p.ionice, value=1)
        finally:
            ioclass, value = init
            if ioclass == psutil.IOPRIO_CLASS_NONE:
                value = 0
            p.ionice(ioclass, value) 
开发者ID:giampaolo,项目名称:psutil,代码行数:43,代码来源:test_process.py

示例4: throttle_backup

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import IOPRIO_CLASS_IDLE [as 别名]
def throttle_backup():
    """
    Makes sure to only us idle IO for backups
    """
    p = psutil.Process(os.getpid())
    p.ionice(psutil.IOPRIO_CLASS_IDLE)
    p.nice(19)
    logging.debug("Process {} was set to use only idle IO and CPU resources".format(p)) 
开发者ID:thelastpickle,项目名称:cassandra-medusa,代码行数:10,代码来源:backup.py

示例5: set_prio_process

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import IOPRIO_CLASS_IDLE [as 别名]
def set_prio_process(nice, ionice):
    ''' The function sets the priority of the current script process. 

    '''

    pid = os.getpid()
    p = psutil.Process(pid)
    p.nice(nice)
    if ionice:
        p.ionice(psutil.IOPRIO_CLASS_IDLE) 
开发者ID:nixys,项目名称:nxs-backup,代码行数:12,代码来源:general_function.py

示例6: test_ionice

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import IOPRIO_CLASS_IDLE [as 别名]
def test_ionice(self):
        if LINUX:
            from psutil import (IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT,
                                IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE)
            self.assertEqual(IOPRIO_CLASS_NONE, 0)
            self.assertEqual(IOPRIO_CLASS_RT, 1)
            self.assertEqual(IOPRIO_CLASS_BE, 2)
            self.assertEqual(IOPRIO_CLASS_IDLE, 3)
            p = psutil.Process()
            try:
                p.ionice(2)
                ioclass, value = p.ionice()
                if enum is not None:
                    self.assertIsInstance(ioclass, enum.IntEnum)
                self.assertEqual(ioclass, 2)
                self.assertEqual(value, 4)
                #
                p.ionice(3)
                ioclass, value = p.ionice()
                self.assertEqual(ioclass, 3)
                self.assertEqual(value, 0)
                #
                p.ionice(2, 0)
                ioclass, value = p.ionice()
                self.assertEqual(ioclass, 2)
                self.assertEqual(value, 0)
                p.ionice(2, 7)
                ioclass, value = p.ionice()
                self.assertEqual(ioclass, 2)
                self.assertEqual(value, 7)
            finally:
                p.ionice(IOPRIO_CLASS_NONE)
        else:
            p = psutil.Process()
            original = p.ionice()
            self.assertIsInstance(original, int)
            try:
                value = 0  # very low
                if original == value:
                    value = 1  # low
                p.ionice(value)
                self.assertEqual(p.ionice(), value)
            finally:
                p.ionice(original) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:46,代码来源:test_process.py


注:本文中的psutil.IOPRIO_CLASS_IDLE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。