发布时间:2019-08-27 08:03:24编辑:auto阅读(4398)
(只用于 Unix , 可选) resource
模块用于查询或修改当前系统资源限制设置. Example
12-10 展示了如何执行查询操作, Example 12-11 展示了如何执行修改操作
import resource
print "usage stats", "=>", resource.getrusage(resource.RUSAGE_SELF)
print "max cpu", "=>", resource.getrlimit(resource.RLIMIT_CPU)
print "max data", "=>", resource.getrlimit(resource.RLIMIT_DATA)
print "max processes", "=>", resource.getrlimit(resource.RLIMIT_NPROC)
print "page size", "=>", resource.getpagesize()
usage stats => (0.03, 0.02, 0, 0, 0, 0, 75, 168, 0, 0, 0, 0, 0, 0, 0, 0)
max cpu => (2147483647, 2147483647)
max data => (2147483647, 2147483647)
max processes => (256, 256)
page size => 4096
File: resource-example-2.py
import resource
resource.setrlimit(resource.RLIMIT_CPU, (0, 1))
# pretend we're busy
for i in range(1000):
for j in range(1000):
for k in range(1000):
pass
上一篇: python 智能提示
下一篇: 《简明python教程》沈洁元
47882
46450
37336
34773
29348
26011
24961
19979
19582
18076
5821°
6449°
5962°
5988°
7095°
5937°
5981°
6472°
6437°
7818°