← All notes

Python resource: measure and limit Unix resource use

Answer: The resource module measures and controls system resources used by a program on Unix.

Where it runs

The module is available on Unix, and not on WASI.

Symbolic constants name particular system resources.

You can ask about the current process or its children.

A failed system call raises OSError.

Soft and hard limits

Each resource has a soft limit and a hard limit.

The soft limit is the current limit, and a process may change it over time.

The soft limit can never exceed the hard limit.

Only a super-user process can raise a hard limit.

getrlimit returns a tuple with the current soft and hard limits.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, resource — Resource usage information; CPython, resource documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, resource — Resource usage information; CPython, resource documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:vv08d587

iinventedlight. 2026. "Python resource: measure and limit Unix resource use." iinventedlight Library, iil:note:vv08d587, version of 2026-11-24. https://iinventedlight.com/library/notes/python-resource/. License: CC-BY-4.0.

@misc{iil_note_vv08d587,
  author = {{iinventedlight}},
  title = {{Python resource: measure and limit Unix resource use}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/python-resource/},
  note = {Permanent ID iil:note:vv08d587. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-resource.md.