diff options
-rw-r--r-- | Doc/library/resource.rst | 15 | ||||
-rw-r--r-- | Lib/test/test_resource.py | 4 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/resource.c | 4 |
4 files changed, 22 insertions, 4 deletions
diff --git a/Doc/library/resource.rst b/Doc/library/resource.rst index 602bd44..c16b013 100644 --- a/Doc/library/resource.rst +++ b/Doc/library/resource.rst @@ -217,14 +217,14 @@ function to specify which processes information should be provided for. .. data:: RUSAGE_SELF - :const:`RUSAGE_SELF` should be used to request information pertaining only to - the process itself. + Pass to :func:`getrusage` to request resources consumed by the calling + process, which is the sum of resources used by all threads in the process. .. data:: RUSAGE_CHILDREN - Pass to :func:`getrusage` to request resource information for child processes of - the calling process. + Pass to :func:`getrusage` to request resources consumed by child processes + of the calling process which have been terminated and waited for. .. data:: RUSAGE_BOTH @@ -232,3 +232,10 @@ function to specify which processes information should be provided for. Pass to :func:`getrusage` to request resources consumed by both the current process and child processes. May not be available on all systems. + +.. data:: RUSAGE_THREAD + + Pass to :func:`getrusage` to request resources consumed by the current + thread. May not be available on all systems. + + .. versionadded:: 3.2 diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py index 4546349..3c9b620 100644 --- a/Lib/test/test_resource.py +++ b/Lib/test/test_resource.py @@ -102,6 +102,10 @@ class ResourceTest(unittest.TestCase): usageboth = resource.getrusage(resource.RUSAGE_BOTH) except (ValueError, AttributeError): pass + try: + usage_thread = resource.getrusage(resource.RUSAGE_THREAD) + except (ValueError, AttributeError): + pass def test_main(verbose=None): support.run_unittest(ResourceTest) @@ -13,6 +13,9 @@ Core and Builtins Library ------- +- Issue #10440: Support RUSAGE_THREAD as a constant in the resource module. + Patch by Robert Collins. + - Issue #10429: IMAP.starttls() stored the capabilities as bytes objects, rather than strings. diff --git a/Modules/resource.c b/Modules/resource.c index 6d8bd57..450f08c 100644 --- a/Modules/resource.c +++ b/Modules/resource.c @@ -325,6 +325,10 @@ PyInit_resource(void) PyModule_AddIntConstant(m, "RUSAGE_BOTH", RUSAGE_BOTH); #endif +#ifdef RUSAGE_THREAD + PyModule_AddIntConstant(m, "RUSAGE_THREAD", RUSAGE_THREAD); +#endif + #if defined(HAVE_LONG_LONG) if (sizeof(RLIM_INFINITY) > sizeof(long)) { v = PyLong_FromLongLong((PY_LONG_LONG) RLIM_INFINITY); |