| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,18 @@ this module for those platforms. | |||
| 52 | 52 | Constant used to represent the limit for an unlimited resource. | |
| 53 | 53 | ||
| 54 | 54 | ||
| 55 | + .. data:: RLIM_SAVED_CUR | ||
| 56 | + .. data:: RLIM_SAVED_MAX | ||
| 57 | + | ||
| 58 | + Constants used to represent the soft and hard limit values if they | ||
| 59 | + cannot be represented in the ``rlim_t`` value in C. | ||
| 60 | + On FreeBSD they are aliases of :data:`RLIM_INFINITY`. | ||
| 61 | + | ||
| 62 | + .. availability:: Solaris, AIX, FreeBSD | ||
| 63 | + | ||
| 64 | + .. versionadded:: next | ||
| 65 | + | ||
| 66 | + | ||
| 55 | 67 | .. function:: getrlimit(resource) | |
| 56 | 68 | ||
| 57 | 69 | Returns a tuple ``(soft, hard)`` with the current soft and hard limits of | |
@@ -177,7 +189,7 @@ platform. | |||
| 177 | 189 | ||
| 178 | 190 | The largest area of mapped memory which the process may occupy. | |
| 179 | 191 | ||
| 180 | - .. availability:: FreeBSD >= 11. | ||
| 192 | + .. availability:: Solaris, FreeBSD. | ||
| 181 | 193 | ||
| 182 | 194 | ||
| 183 | 195 | .. data:: RLIMIT_AS | |
@@ -230,6 +242,7 @@ platform. | |||
| 230 | 242 | ||
| 231 | 243 | .. versionadded:: 3.4 | |
| 232 | 244 | ||
| 245 | + | ||
| 233 | 246 | .. data:: RLIMIT_SBSIZE | |
| 234 | 247 | ||
| 235 | 248 | The maximum size (in bytes) of socket buffer usage for this user. | |
@@ -240,6 +253,7 @@ platform. | |||
| 240 | 253 | ||
| 241 | 254 | .. versionadded:: 3.4 | |
| 242 | 255 | ||
| 256 | + | ||
| 243 | 257 | .. data:: RLIMIT_SWAP | |
| 244 | 258 | ||
| 245 | 259 | The maximum size (in bytes) of the swap space that may be reserved or | |
@@ -249,18 +263,20 @@ platform. | |||
| 249 | 263 | `tuning(7) <https://man.freebsd.org/cgi/man.cgi?query=tuning&sektion=7>`__ | |
| 250 | 264 | for a complete description of this sysctl. | |
| 251 | 265 | ||
| 252 | - .. availability:: FreeBSD. | ||
| 266 | + .. availability:: FreeBSD >= 8. | ||
| 253 | 267 | ||
| 254 | 268 | .. versionadded:: 3.4 | |
| 255 | 269 | ||
| 270 | + | ||
| 256 | 271 | .. data:: RLIMIT_NPTS | |
| 257 | 272 | ||
| 258 | 273 | The maximum number of pseudo-terminals created by this user id. | |
| 259 | 274 | ||
| 260 | - .. availability:: FreeBSD. | ||
| 275 | + .. availability:: FreeBSD >= 8. | ||
| 261 | 276 | ||
| 262 | 277 | .. versionadded:: 3.4 | |
| 263 | 278 | ||
| 279 | + | ||
| 264 | 280 | .. data:: RLIMIT_KQUEUES | |
| 265 | 281 | ||
| 266 | 282 | The maximum number of kqueues this user id is allowed to create. | |
@@ -269,6 +285,36 @@ platform. | |||
| 269 | 285 | ||
| 270 | 286 | .. versionadded:: 3.10 | |
| 271 | 287 | ||
| 288 | + | ||
| 289 | + .. data:: RLIMIT_NTHR | ||
| 290 | + | ||
| 291 | + The maximum number of threads for this user id, not counting the main | ||
| 292 | + and kernel threads. | ||
| 293 | + | ||
| 294 | + .. availability:: NetBSD >= 7.0. | ||
| 295 | + | ||
| 296 | + .. versionadded:: next | ||
| 297 | + | ||
| 298 | + | ||
| 299 | + .. data:: RLIMIT_THREADS | ||
| 300 | + | ||
| 301 | + The maximum number of threads each process can create. | ||
| 302 | + | ||
| 303 | + .. availability:: AIX. | ||
| 304 | + | ||
| 305 | + .. versionadded:: next | ||
| 306 | + | ||
| 307 | + | ||
| 308 | + .. data:: RLIMIT_UMTXP | ||
| 309 | + | ||
| 310 | + The limit of the number of process-shared Posix thread library objects | ||
| 311 | + allocated by user id. | ||
| 312 | + | ||
| 313 | + .. availability:: FreeBSD >= 11. | ||
| 314 | + | ||
| 315 | + .. versionadded:: next | ||
| 316 | + | ||
| 317 | + | ||
| 272 | 318 | Resource Usage | |
| 273 | 319 | -------------- | |
| 274 | 320 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -277,6 +277,15 @@ os.path | |||
| 277 | 277 | the resulting path can be missing but it will be free of symlinks. | |
| 278 | 278 | (Contributed by Petr Viktorin for :cve:`2025-4517`.) | |
| 279 | 279 | ||
| 280 | + resource | ||
| 281 | + -------- | ||
| 282 | + | ||
| 283 | + * Add new constants: :data:`~resource.RLIMIT_NTHR`, | ||
| 284 | + :data:`~resource.RLIMIT_UMTXP`, :data:`~resource.RLIMIT_THREADS`, | ||
| 285 | + :data:`~resource.RLIM_SAVED_CUR`, and :data:`~resource.RLIM_SAVED_MAX`. | ||
| 286 | + (Contributed by Serhiy Storchaka in :gh:`137512`.) | ||
| 287 | + | ||
| 288 | + | ||
| 280 | 289 | shelve | |
| 281 | 290 | ------ | |
| 282 | 291 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -200,14 +200,23 @@ def test_pagesize(self): | |||
| 200 | 200 | self.assertIsInstance(pagesize, int) | |
| 201 | 201 | self.assertGreaterEqual(pagesize, 0) | |
| 202 | 202 | ||
| 203 | + def test_contants(self): | ||
| 204 | + self.assertIsInstance(resource.RLIM_INFINITY, int) | ||
| 205 | + if sys.platform.startswith(('freebsd', 'solaris', 'sunos', 'aix')): | ||
| 206 | + self.assertHasAttr(resource, 'RLIM_SAVED_CUR') | ||
| 207 | + self.assertHasAttr(resource, 'RLIM_SAVED_MAX') | ||
| 208 | + if hasattr(resource, 'RLIM_SAVED_CUR'): | ||
| 209 | + self.assertIsInstance(resource.RLIM_SAVED_CUR, int) | ||
| 210 | + self.assertIsInstance(resource.RLIM_SAVED_MAX, int) | ||
| 211 | + | ||
| 203 | 212 | @unittest.skipUnless(sys.platform in ('linux', 'android'), 'Linux only') | |
| 204 | 213 | def test_linux_constants(self): | |
| 205 | 214 | for attr in ['MSGQUEUE', 'NICE', 'RTPRIO', 'RTTIME', 'SIGPENDING']: | |
| 206 | 215 | with contextlib.suppress(AttributeError): | |
| 207 | 216 | self.assertIsInstance(getattr(resource, 'RLIMIT_' + attr), int) | |
| 208 | 217 | ||
| 209 | 218 | def test_freebsd_contants(self): | |
| 210 | - for attr in ['SWAP', 'SBSIZE', 'NPTS']: | ||
| 219 | + for attr in ['SWAP', 'SBSIZE', 'NPTS', 'UMTXP', 'VMEM']: | ||
| 211 | 220 | with contextlib.suppress(AttributeError): | |
| 212 | 221 | self.assertIsInstance(getattr(resource, 'RLIMIT_' + attr), int) | |
| 213 | 222 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + Add new constants in the :mod:`resource` module: | ||
| 2 | + :data:`~resource.RLIMIT_NTHR`, :data:`~resource.RLIMIT_UMTXP`, | ||
| 3 | + :data:`~resource.RLIMIT_THREADS`, :data:`~resource.RLIM_SAVED_CUR`, and | ||
| 4 | + :data:`~resource.RLIM_SAVED_MAX`. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -518,9 +518,38 @@ resource_exec(PyObject *module) | |||
| 518 | 518 | ADD_INT(module, RLIMIT_KQUEUES); | |
| 519 | 519 | #endif | |
| 520 | 520 | ||
| 521 | + #ifdef RLIMIT_NTHR | ||
| 522 | + ADD_INT(module, RLIMIT_NTHR); | ||
| 523 | + #endif | ||
| 524 | + | ||
| 525 | + #ifdef RLIMIT_THREADS | ||
| 526 | + ADD_INT(module, RLIMIT_THREADS); | ||
| 527 | + #endif | ||
| 528 | + | ||
| 529 | + #ifdef RLIMIT_UMTXP | ||
| 530 | + ADD_INT(module, RLIMIT_UMTXP); | ||
| 531 | + #endif | ||
| 532 | + | ||
| 533 | + #ifdef RLIMIT_PIPEBUF | ||
| 534 | + ADD_INT(module, RLIMIT_PIPEBUF); | ||
| 535 | + #endif | ||
| 536 | + | ||
| 521 | 537 | if (PyModule_Add(module, "RLIM_INFINITY", rlim2py(RLIM_INFINITY)) < 0) { | |
| 522 | 538 | return -1; | |
| 523 | 539 | } | |
| 540 | + | ||
| 541 | + #ifdef RLIM_SAVED_CUR | ||
| 542 | + if (PyModule_Add(module, "RLIM_SAVED_CUR", rlim2py(RLIM_SAVED_CUR)) < 0) { | ||
| 543 | + return -1; | ||
| 544 | + } | ||
| 545 | + #endif | ||
| 546 | + | ||
| 547 | + #ifdef RLIM_SAVED_MAX | ||
| 548 | + if (PyModule_Add(module, "RLIM_SAVED_MAX", rlim2py(RLIM_SAVED_MAX)) < 0) { | ||
| 549 | + return -1; | ||
| 550 | + } | ||
| 551 | + #endif | ||
| 552 | + | ||
| 524 | 553 | return 0; | |
| 525 | 554 | ||
| 526 | 555 | #undef ADD_INT | |
| Back | FazBrowse Home | New Git URL |
0 commit comments