shanecode / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

(Linux) process resource limits (prlimit(2)) #412

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Linux has a function (prlimit(2)) which allows to get/set resource limits for a 
certain process.

With this you can, say, instruct a process so that it uses no more than a 
certain amount of memory or opens no more than a certain number of files, see:
http://linux.die.net/man/2/prlimit

There's also a proposal for inclusion of prlimit(2) into Python 3.4, see:
http://bugs.python.org/issue16595

Proposal is to provide the same functionality in psutil by providing two new 
functions behaving along these lines:

>>> p = psutil.Process(pid)
>>> p.get_rlimit(psutil.RLIMIT_NOFILE)
(1024, 4096)
>>> p.set_rlimit(psutil.RLIMIT_NOFILE, (5, 5))
>>> p.get_rlimit(psutil.RLIMIT_NOFILE)
(5, 5)
>>>

Basically this would be equivalent to resource's module getrlimit() and 
setrlimit() functions but applicable to any process/pid (as opposed to current 
process only):
http://docs.python.org/2/library/resource.html

Original issue reported on code.google.com by g.rodola on 24 Jul 2013 at 11:56

GoogleCodeExporter commented 9 years ago
Implemented in revision cda9980f2abd.

Original comment by g.rodola on 24 Jul 2013 at 9:41

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 28 Sep 2013 at 10:06

GoogleCodeExporter commented 9 years ago
Closing out as fixed. Release 1.1.0 is now available for download.

Original comment by g.rodola on 28 Sep 2013 at 5:32