Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
giampaolo opened this issue May 23, 2014 · 4 comments
Closed

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

giampaolo opened this issue May 23, 2014 · 4 comments

Comments

@giampaolo
Copy link
Owner

From g.rodola on July 24, 2013 13:56:04

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: http://code.google.com/p/psutil/issues/detail?id=412

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From g.rodola on July 24, 2013 14:41:29

Implemented in revision cda9980f2abd .

Status: FixedInHG
Labels: OpSys-Linux Milestone-1.1.0

@giampaolo
Copy link
Owner Author

From g.rodola on September 28, 2013 03:06:18

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on September 28, 2013 10:32:46

Closing out as fixed. Release 1.1.0 is now available for download.

@MengHao666
Copy link

what is "pid" in your code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants