[Python-checkins] cpython: Issue #19343: Expose FreeBSD-specific APIs in resource module. Original patch

christian.heimes python-checkins at python.org
Sun Dec 8 14:36:15 CET 2013


http://hg.python.org/cpython/rev/ad2cd599f1cf
changeset:   87829:ad2cd599f1cf
user:        Christian Heimes <christian at cheimes.de>
date:        Sun Dec 08 14:35:55 2013 +0100
summary:
  Issue #19343: Expose FreeBSD-specific APIs in resource module.  Original patch by Koobs.

files:
  Doc/library/resource.rst  |  28 +++++++++++++++++++++++++++
  Lib/test/test_resource.py |   6 +++++
  Misc/NEWS                 |   3 ++
  Modules/resource.c        |  14 +++++++++++++
  4 files changed, 51 insertions(+), 0 deletions(-)


diff --git a/Doc/library/resource.rst b/Doc/library/resource.rst
--- a/Doc/library/resource.rst
+++ b/Doc/library/resource.rst
@@ -217,6 +217,34 @@
 
    .. versionadded:: 3.4
 
+.. data:: RLIMIT_SBSIZE
+
+   The maximum size (in bytes) of socket buffer usage for this user.
+   This limits the amount of network memory, and hence the amount of mbufs,
+   that this user may hold at any time.
+
+   Availability: FreeBSD 9 or later.
+
+   .. versionadded:: 3.4
+
+.. data:: RLIMIT_SWAP
+
+   The maximum size (in bytes) of the swap space that may be reserved or
+   used by all of this user id's processes.
+   This limit is enforced only if bit 1 of the vm.overcommit sysctl is set.
+   Please see :manpage:`tuning(7)` for a complete description of this sysctl.
+
+   Availability: FreeBSD 9 or later.
+
+   .. versionadded:: 3.4
+
+.. data:: RLIMIT_NPTS
+
+   The maximum number of pseudo-terminals created by this user id.
+
+   Availability: FreeBSD 9 or later.
+
+   .. versionadded:: 3.4
 
 Resource Usage
 --------------
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -138,6 +138,12 @@
             with contextlib.suppress(AttributeError):
                 self.assertIsInstance(getattr(resource, 'RLIMIT_' + attr), int)
 
+    @support.requires_freebsd_version(9)
+    def test_freebsd_contants(self):
+        for attr in ['SWAP', 'SBSIZE', 'NPTS']:
+            with contextlib.suppress(AttributeError):
+                self.assertIsInstance(getattr(resource, 'RLIMIT_' + attr), int)
+
     @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
     @support.requires_linux_version(2, 6, 36)
     def test_prlimit(self):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,9 @@
 Library
 -------
 
+- Issue #19343: Expose FreeBSD-specific APIs in resource module.  Original
+  patch by Koobs.
+
 - Issue #19506: Use a memoryview to avoid a data copy when piping data
   to stdin within subprocess.Popen.communicate.  5-10% less cpu usage.
 
diff --git a/Modules/resource.c b/Modules/resource.c
--- a/Modules/resource.c
+++ b/Modules/resource.c
@@ -424,6 +424,20 @@
     PyModule_AddIntMacro(m, RUSAGE_THREAD);
 #endif
 
+/* FreeBSD specific */
+
+#ifdef RLIMIT_SWAP
+    PyModule_AddIntMacro(m, RLIMIT_SWAP);
+#endif
+
+#ifdef RLIMIT_SBSIZE
+    PyModule_AddIntMacro(m, RLIMIT_SBSIZE);
+#endif
+
+#ifdef RLIMIT_NPTS
+    PyModule_AddIntMacro(m, RLIMIT_NPTS);
+#endif
+
 #if defined(HAVE_LONG_LONG)
     if (sizeof(RLIM_INFINITY) > sizeof(long)) {
         v = PyLong_FromLongLong((PY_LONG_LONG) RLIM_INFINITY);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list