]> granicus.if.org Git - python/commitdiff
Issue #19324: Expose Linux-specific constants in resource module
authorChristian Heimes <christian@cheimes.de>
Tue, 22 Oct 2013 09:09:27 +0000 (11:09 +0200)
committerChristian Heimes <christian@cheimes.de>
Tue, 22 Oct 2013 09:09:27 +0000 (11:09 +0200)
Doc/library/resource.rst
Lib/test/test_resource.py
Misc/NEWS
Modules/resource.c

index ed858505a7e024dbcd2b6f8b309aba4444750149..1c0fa9fafa3bf5fdccedcd3d7d3273bae02f5fd1 100644 (file)
@@ -151,6 +151,52 @@ platform.
    The maximum area (in bytes) of address space which may be taken by the process.
 
 
+.. data:: RLIMIT_MSGQUEUE
+
+   The number of bytes that can be allocated for POSIX message queues.
+
+   Availability: Linux 2.6.8 or later.
+
+   .. versionadded:: 3.4
+
+
+.. data:: RLIMIT_NICE
+
+   The ceiling for the process's nice level (calculated as 20 - rlim_cur).
+
+   Availability: Linux 2.6.12 or later.
+
+   .. versionadded:: 3.4
+
+
+.. data:: RLIMIT_RTPRIO
+
+   The ceiling of the real-time priority.
+
+   Availability: Linux 2.6.12 or later.
+
+   .. versionadded:: 3.4
+
+
+.. data:: RLIMIT_RTTIME
+
+   The time limit (in microseconds) on CPU time that a process can spend
+   under real-time scheduling without making a blocking syscall.
+
+   Availability: Linux 2.6.25 or later.
+
+   .. versionadded:: 3.4
+
+
+.. data:: RLIMIT_SIGPENDING
+
+   The number of signals which the process may queue.
+
+   Availability: Linux 2.6.8 or later.
+
+   .. versionadded:: 3.4
+
+
 Resource Usage
 --------------
 
index 1bf2a5a6cecc0d487638a584d68c96504ff081a2..3c9c9a8292b255e6be65c943208049df6a0add3d 100644 (file)
@@ -1,3 +1,4 @@
+import sys
 import unittest
 from test import support
 import time
@@ -129,6 +130,15 @@ class ResourceTest(unittest.TestCase):
         self.assertIsInstance(pagesize, int)
         self.assertGreaterEqual(pagesize, 0)
 
+    @unittest.skipUnless(sys.platform == 'linux', 'test requires Linux')
+    def test_linux_constants(self):
+        self.assertIsInstance(resource.RLIMIT_MSGQUEUE, int)
+        self.assertIsInstance(resource.RLIMIT_NICE, int)
+        self.assertIsInstance(resource.RLIMIT_RTPRIO, int)
+        self.assertIsInstance(resource.RLIMIT_RTTIME, int)
+        self.assertIsInstance(resource.RLIMIT_SIGPENDING, int)
+
+
 def test_main(verbose=None):
     support.run_unittest(ResourceTest)
 
index d23f0a8e51e60c8efa00450328a460b279b3979b..3d512d70d1d133756bcd17a9c4874170247259fa 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #19324: Expose Linux-specific constants in resource module.
+
 - Issue #17400: ipaddress should make it easy to identify rfc6598 addresses.
 
 - Load SSL's error strings in hashlib.
index 876831537236f615b46afef449fc23539e9a04de..0ae24c0bb901372e05340232fcb5f5137ab40b47 100644 (file)
@@ -326,6 +326,28 @@ PyInit_resource(void)
     PyModule_AddIntMacro(m, RLIMIT_SBSIZE);
 #endif
 
+/* Linux specific */
+#ifdef RLIMIT_MSGQUEUE
+    PyModule_AddIntMacro(m, RLIMIT_MSGQUEUE);
+#endif
+
+#ifdef RLIMIT_NICE
+    PyModule_AddIntMacro(m, RLIMIT_NICE);
+#endif
+
+#ifdef RLIMIT_RTPRIO
+    PyModule_AddIntMacro(m, RLIMIT_RTPRIO);
+#endif
+
+#ifdef RLIMIT_RTTIME
+    PyModule_AddIntMacro(m, RLIMIT_RTTIME);
+#endif
+
+#ifdef RLIMIT_SIGPENDING
+    PyModule_AddIntMacro(m, RLIMIT_SIGPENDING);
+#endif
+
+/* target */
 #ifdef RUSAGE_SELF
     PyModule_AddIntMacro(m, RUSAGE_SELF);
 #endif