resource
| Use Case | Command | Description |
|---|---|---|
| 🔍 Check CPU time limit | resource.getrlimit(resource.RLIMIT_CPU) | Returns (soft, hard) limits for CPU time in seconds |
| 📂 Set open file limit | resource.setrlimit(resource.RLIMIT_NOFILE, (1024, 4096)) | Sets soft limit to 1024, hard limit to 4096 file descriptors |
| 📊 Measure memory usage | resource.getrusage(resource.RUSAGE_SELF).ru_maxrss | Returns max resident set size in kilobytes |
| 📄 Get system page size | resource.getpagesize() | Returns page size in bytes |
| 👥 Limit another process | resource.prlimit(pid, resource.RLIMIT_NPROC, (100, 200)) | Sets max processes for given PID |
| 🧒 Child process usage | resource.getrusage(resource.RUSAGE_CHILDREN) | Returns cumulative usage of all terminated children |
https://docs.python.org/3.10/library/resource.html
The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.
builtins.tuple(builtins.object)
struct_rusage
struct_rusage: Result from getrusage.
This object may be accessed either as a tuple of
(utime,stime,maxrss,ixrss,idrss,isrss,minflt,majflt,nswap,inblock,oublock,msgsnd,msgrcv,nsignals,nvcsw,nivcsw)
or via the attributes ru_utime, ru_stime, ru_maxrss, and so on.
Method resolution order:
__reduce__(...) — Helper for pickle.__repr__(self, /) — Return repr(self).__new__(*args, **kwargs) from builtins.type — Create and return a new object. See help(type) for accurate signature.ru_idrss — unshared data sizeru_inblock — block input operationsru_isrss — unshared stack sizeru_ixrss — shared memory sizeru_majflt — page faults requiring I/Oru_maxrss — max. resident set sizeru_minflt — page faults not requiring I/Oru_msgrcv — IPC messages receivedru_msgsnd — IPC messages sentru_nivcsw — involuntary context switchesru_nsignals — signals receivedru_nswap — number of swap outsru_nvcsw — voluntary context switchesru_oublock — block output operationsru_stime — system time usedru_utime — user time used__match_args__ = ('ru_utime', 'ru_stime', 'ru_maxrss', 'ru_ixrss', 'ru...')n_fields = 16n_sequence_fields = 16n_unnamed_fields = 0__add__(self, value, /) — Return self+value.__contains__(self, key, /) — Return key in self.__eq__(self, value, /) — Return self==value.__ge__(self, value, /) — Return self>=value.__getattribute__(self, name, /) — Return getattr(self, name).__getitem__(self, key, /) — Return self[key].__getnewargs__(self, /)__gt__(self, value, /) — Return self>value.__hash__(self, /) — Return hash(self).__iter__(self, /) — Implement iter(self).__le__(self, value, /) — Return self<=value.__len__(self, /) — Return len(self).__lt__(self, value, /) — Return self<value.__mul__(self, value, /) — Return self*value.__ne__(self, value, /) — Return self!=value.__rmul__(self, value, /) — Return value*self.count(self, value, /) — Return number of occurrences of value.index(self, value, start=0, stop=9223372036854775807, /) — Return first index of value. Raises ValueError if the value is not present.__class_getitem__(...) from builtins.type — See PEP 585getpagesize() — Returns the system page size in bytes.getrlimit(resource, /) — Returns a tuple (soft, hard) of the current resource limit.getrusage(who, /) — Returns a struct_rusage object with resource usage for the current process, children, or thread.prlimit(pid, resource, [limits]) — Combines setrlimit and getrlimit; if limits is omitted, returns the current limit for pid; otherwise sets the limit and returns the old limit.setrlimit(resource, limits, /) — Sets new resource limits.RLIMIT_AS = 9 — Address space limitRLIMIT_CORE = 4 — Core file size limitRLIMIT_CPU = 0 — CPU time limitRLIMIT_DATA = 2 — Data segment size limitRLIMIT_FSIZE = 1 — File size limitRLIMIT_MEMLOCK = 8 — Locked memory limitRLIMIT_MSGQUEUE = 12 — POSIX message queue limitRLIMIT_NICE = 13 — Nice value limitRLIMIT_NOFILE = 7 — Open file descriptors limitRLIMIT_NPROC = 6 — Number of processes limitRLIMIT_OFILE = 7 — (alias for RLIMIT_NOFILE)RLIMIT_RSS = 5 — Resident set size limitRLIMIT_RTPRIO = 14 — Real-time priority limitRLIMIT_RTTIME = 15 — Real-time CPU time limitRLIMIT_SIGPENDING = 11 — Pending signals limitRLIMIT_STACK = 3 — Stack size limitRLIM_INFINITY = -1 — No limitRUSAGE_CHILDREN = -1 — Usage for all terminated childrenRUSAGE_SELF = 0 — Usage for the calling processRUSAGE_THREAD = 1 — Usage for the calling thread/usr/lib/python3.10/lib-dynload/resource.cpython-310-x86_64-linux-gnu.so
Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 16:17 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format