python resource模块使用
Posted 邱明成
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python resource模块使用相关的知识,希望对你有一定的参考价值。
import os
import psutil
import resource
import subprocess
def preexec_fn():
pid = os.getpid()
ps = psutil.Process(pid)
ps.set_nice(10)
resource.setrlimit(resource.RLIMIT_CPU, (1, 1))
print"mother pid", os.getpid()
p = subprocess.Popen(["./cpuhog.sh"], preexec_fn=preexec_fn)
p.wait()
print"mother still alive with pid", os.getpid()
以上是关于python resource模块使用的主要内容,如果未能解决你的问题,请参考以下文章