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


Python psutil.BELOW_NORMAL_PRIORITY_CLASS属性代码示例

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


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

示例1: start

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import BELOW_NORMAL_PRIORITY_CLASS [as 别名]
def start(self):
        log.debug("SubProcess.start(): create_subprocess_exec...", extra={"task": self.defname})
        if sys.platform == "win32":
            # To prevent engines opening console window
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        else:
            startupinfo = None

        create = asyncio.create_subprocess_exec(* self.argv,
                                                stdin=asyncio.subprocess.PIPE,
                                                stdout=asyncio.subprocess.PIPE,
                                                startupinfo=startupinfo,
                                                env=self.env,
                                                cwd=self.cwd)
        try:
            self.proc = await asyncio.wait_for(create, TIME_OUT_SECOND)
            self.pid = self.proc.pid
            # print(self.pid, self.path)
            if self.lowPriority:
                proc = psutil.Process(self.pid)
                if sys.platform == "win32":
                    niceness = psutil.BELOW_NORMAL_PRIORITY_CLASS
                else:
                    niceness = 15  # The higher, the lower the priority
                if psutil.__version__ >= "2.0.0":
                    proc.nice(niceness)
                else:
                    proc.set_nice(niceness)
            self.read_stdout_task = create_task(self.read_stdout(self.proc.stdout))
            self.write_task = None
        except asyncio.TimeoutError:
            log.warning("TimeoutError", extra={"task": self.defname})
            raise
        except GLib.GError:
            log.warning("GLib.GError", extra={"task": self.defname})
            raise
        except Exception:
            e = sys.exc_info()[0]
            log.warning("%s" % e, extra={"task": self.defname})
            raise 
开发者ID:pychess,项目名称:pychess,代码行数:43,代码来源:SubProcess.py

示例2: set_priority

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import BELOW_NORMAL_PRIORITY_CLASS [as 别名]
def set_priority(level, pid=None):
    """Set the priority/nice of the application.
    
    Numbers may be used (in the style of Linux from -20 (high) to 19 (low),
    or as text, such as 'belownormal' or 'realtime'.
    """
    process = psutil.Process(pid)
    try:
        level = level.lower().replace(' ', '')
        
        if level == 'realtime':
            process.nice(psutil.REALTIME_PRIORITY_CLASS)
        elif level == 'high':
            process.nice(psutil.HIGH_PRIORITY_CLASS)
        elif level == 'abovenormal':
            process.nice(psutil.ABOVE_NORMAL_PRIORITY_CLASS)
        elif level == 'normal':
            process.nice(psutil.NORMAL_PRIORITY_CLASS)
        elif level == 'belownormal':
            process.nice(psutil.BELOW_NORMAL_PRIORITY_CLASS)
        if level == 'low':
            process.nice(psutil.IDLE_PRIORITY_CLASS)
            
    except AttributeError:
        if level < -13:
            process.nice(psutil.REALTIME_PRIORITY_CLASS)
        elif -13 <= level < -7:
            process.nice(psutil.HIGH_PRIORITY_CLASS)
        elif -7 <= level < 0:
            process.nice(psutil.ABOVE_NORMAL_PRIORITY_CLASS)
        elif 0 <= level < 7:
            process.nice(psutil.NORMAL_PRIORITY_CLASS)
        elif 7 <= level < 12:
            process.nice(psutil.BELOW_NORMAL_PRIORITY_CLASS)
        elif 13 <= level:
            process.nice(psutil.IDLE_PRIORITY_CLASS) 
开发者ID:Peter92,项目名称:MouseTracks,代码行数:38,代码来源:__init__.py

示例3: Quell

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import BELOW_NORMAL_PRIORITY_CLASS [as 别名]
def Quell(name):
	time.sleep(1)
	#加入延时是因为x264需要一定时间才能启动
	#如果立刻抓取进程列表的话会看不到x264压制进程
	for proc in psutil.process_iter():
		if name in proc.name():
			proc.nice(psutil.BELOW_NORMAL_PRIORITY_CLASS) 
开发者ID:Kilo19,项目名称:NixieVideoKit,代码行数:9,代码来源:nvksupport.py

示例4: set_low_process_priority

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import BELOW_NORMAL_PRIORITY_CLASS [as 别名]
def set_low_process_priority():
    p = psutil.Process(os.getpid())
    if sys.platform == "win32":
        p.nice(psutil.BELOW_NORMAL_PRIORITY_CLASS)
    else:
        p.nice(5) 
开发者ID:bhansconnect,项目名称:alpha_zero_othello,代码行数:8,代码来源:util.py

示例5: test_nice

# 需要导入模块: import psutil [as 别名]
# 或者: from psutil import BELOW_NORMAL_PRIORITY_CLASS [as 别名]
def test_nice(self):
        p = psutil.Process()
        self.assertRaises(TypeError, p.nice, "str")
        init = p.nice()
        try:
            if WINDOWS:
                for prio in [psutil.NORMAL_PRIORITY_CLASS,
                             psutil.IDLE_PRIORITY_CLASS,
                             psutil.BELOW_NORMAL_PRIORITY_CLASS,
                             psutil.REALTIME_PRIORITY_CLASS,
                             psutil.HIGH_PRIORITY_CLASS,
                             psutil.ABOVE_NORMAL_PRIORITY_CLASS]:
                    with self.subTest(prio=prio):
                        try:
                            p.nice(prio)
                        except psutil.AccessDenied:
                            pass
                        else:
                            self.assertEqual(p.nice(), prio)
            else:
                try:
                    if hasattr(os, "getpriority"):
                        self.assertEqual(
                            os.getpriority(os.PRIO_PROCESS, os.getpid()),
                            p.nice())
                    p.nice(1)
                    self.assertEqual(p.nice(), 1)
                    if hasattr(os, "getpriority"):
                        self.assertEqual(
                            os.getpriority(os.PRIO_PROCESS, os.getpid()),
                            p.nice())
                    # XXX - going back to previous nice value raises
                    # AccessDenied on MACOS
                    if not MACOS:
                        p.nice(0)
                        self.assertEqual(p.nice(), 0)
                except psutil.AccessDenied:
                    pass
        finally:
            try:
                p.nice(init)
            except psutil.AccessDenied:
                pass 
开发者ID:giampaolo,项目名称:psutil,代码行数:45,代码来源:test_process.py


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