-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Add resource.prlimit #60799
Comments
Linux has an additional function to setrlimit and getrlimit which supports to query and/or modify resource limits of another process. http://www.kernel.org/doc/man-pages/online/pages/man2/getrlimit.2.html The patch implements resource.prlimit(pid, resource[, limits]) on all platforms that have a prlimit() function. I haven't included the regenerated configure script. You have to run autoreconf in order to test the new function. |
prlimit() needs glibc 2.13+ (thanks Arfrever). |
Updated patch, now raises PermissionError on EPERM. |
Does anybody want to review the code before I commit it? |
From my original post which unfortunately was ignored :( : RLIMIT_MSGQUEUE |
Fedora 18, this is the result after applying your patch and execute your unit test: [sky@localhost cpython]$ ./python Lib/test/test_resource.py ====================================================================== Traceback (most recent call last):
File "Lib/test/test_resource.py", line 131, in test_prlimit
1, resource.RLIMIT_AS)
File "/home/sky/Code/python/programming_language/cpython/Lib/unittest/case.py", line 614, in assertRaises
return context.handle('assertRaises', callableObj, args, kwargs)
File "/home/sky/Code/python/programming_language/cpython/Lib/unittest/case.py", line 150, in handle
callable_obj(*args, **kwargs)
PermissionError: [Errno 1] Operation not permitted Ran 7 tests in 0.990s FAILED (errors=1)
Traceback (most recent call last):
File "Lib/test/test_resource.py", line 143, in <module>
test_main()
File "Lib/test/test_resource.py", line 140, in test_main
support.run_unittest(ResourceTest)
File "/home/sky/Code/python/programming_language/cpython/Lib/test/support.py", line 1615, in run_unittest
_run_suite(suite)
File "/home/sky/Code/python/programming_language/cpython/Lib/test/support.py", line 1590, in _run_suite
raise TestFailed(err)
test.support.TestFailed: Traceback (most recent call last):
File "Lib/test/test_resource.py", line 131, in test_prlimit
1, resource.RLIMIT_AS)
File "/home/sky/Code/python/programming_language/cpython/Lib/unittest/case.py", line 614, in assertRaises
return context.handle('assertRaises', callableObj, args, kwargs)
File "/home/sky/Code/python/programming_language/cpython/Lib/unittest/case.py", line 150, in handle
callable_obj(*args, **kwargs)
PermissionError: [Errno 1] Operation not permitted With sudo, I got this: [sky@localhost cpython]$ sudo ./python Lib/test/test_resource.py ====================================================================== Traceback (most recent call last):
File "Lib/test/test_resource.py", line 131, in test_prlimit
1, resource.RLIMIT_AS)
AssertionError: ValueError not raised by prlimit Ran 7 tests in 1.002s FAILED (failures=1)
Traceback (most recent call last):
File "Lib/test/test_resource.py", line 143, in <module>
test_main()
File "Lib/test/test_resource.py", line 140, in test_main
support.run_unittest(ResourceTest)
File "/home/sky/Code/python/programming_language/cpython/Lib/test/support.py", line 1615, in run_unittest
_run_suite(suite)
File "/home/sky/Code/python/programming_language/cpython/Lib/test/support.py", line 1590, in _run_suite
raise TestFailed(err)
test.support.TestFailed: Traceback (most recent call last):
File "Lib/test/test_resource.py", line 131, in test_prlimit
1, resource.RLIMIT_AS)
AssertionError: ValueError not raised by prlimit |
Thanks for your tests. I may have to rework my test scenario a bit. |
New changeset 796c21e27a92 by Christian Heimes in branch 'default': |
Let's see how the buildbots respond. I may have to disable some tests for ancient Kernel versions. |
+ self.assertRaises(PermissionError, resource.prlimit, Please skip this when run as root. + self.assertEqual(resource.prlimit(0, resource.RLIMIT_AS), (-1, -1)) What if it's not that value by default? Please fix the test to make it |
Roundup bot hangs. I have addressed your concerns in http://hg.python.org/cpython/rev/8c77117f41a9 |
The test is failing with ENOSYS on one of the buildbots: Traceback (most recent call last):
File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/test_resource.py", line 148, in test_prlimit
1, resource.RLIMIT_AS)
File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/unittest/case.py", line 689, in assertRaises
return context.handle('assertRaises', callableObj, args, kwargs)
File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/unittest/case.py", line 158, in handle
callable_obj(*args, **kwargs)
OSError: [Errno 38] Function not implemented
""" I wonder if we could add a @support.ignore_enosys decorator... |
New changeset 87d41a5a9077 by Christian Heimes in branch 'default': |
The buildbot is Linux-2.6.35-vs2.3.0.36.32-gentoo-i686-Intel-R-Core-TM-2_CPU_6600@_2.40GHz-with-gentoo-2.1 but prlimit() requires 2.6.36+. I didn't expect to see a combination of glibc with prlimit() and Kernel without prlimit(). According to man prlimit it's not suppose to fail with ENOSYS, too. |
Or we should extend with supress(OSerror, errno=errno.ENOSYS): ... :-) (Just kidding, ignored tests must be marked as skipped.) |
Yeah, we've seen this several times on some buildbots. |
Tests are passing on all buildbots for quite some time now. |
Just received this report on psutil bug tracker: >>> import resource
>>> resource.RLIM_INFINITY
-1
>>> |
s/os.prlimit/resource.prlimit |
How is that a problem? In any case, this shouldn't have anything to do with prlimit(), please open another issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: