Python Introduction to Resource Library

Python Introduction to Resource Library

Resource Python Library

Computers have evolved over time in a better way and in today's world, almost all the tasks are performed efficiently using computers. For performing these tasks, computers make use of the resources available to it. We always try to keep the utilization of the computer resources in the best possible way, which also aids in increasing the throughput and response times of the computer.

This module in python provides basic mechanisms for measuring and controlling system resources utilized by a program.

Symbolic constants are used to specify particular system resources and to request usage information about either the current process or its children. If there is a syscall failure, the OSError is raised.

Let's first talk about some such symbols related to the resource limits in this module.
These symbols basically define resources whose consumption can be controlled using the setrlimit() and getrlimit() functions described in the later article(Python resource library limit symbolic constants continued). The values of these symbols are exactly the constants used by C programs.

The following symbols are useful in using the resource library resource limit functions.

This is the limit for an unlimited resource.

This attribute returns the maximum size in bytes of a core file that the current process can create. This may result in the creation of a partial core file if a larger core would be required to contain the entire process image.
The core file of a process contains the detailed copy of the state of the process at the instant of its failure, including the process registers and memory(which includes shared memory depending upon configuration details). With the help of this picture we can extrapolate backward in time to find the initial mistake that led to the failure. With the properly collected core files and associated information, we can solve, or otherwise extract the information about the failing process.

This is the maximum amount of processor time in seconds that the process can use. If the time limit exceeds, then a SIGXCPU signal is sent to the process which results in the default action of abnormal termination of the process.

This returns the maximum size of the file that the process is allowed to create.

This gives the maximum size in bytes of the process's heap. Heap memory (also called the dynamic memory) is essentially a large pool of memory (typically per process) from which the running program can request chunks.

This gives the maximum size in bytes of the call stack for the current process. This only affects the stack of the main thread in the multithreaded process.
The call stack is the mechanism for an interpreter to keep track of its place in the script that calls multiple functions like what function is currently running and what functions are called from within the function etc. 

This gives the maximum resident set size that should be made available to the process.
The Resident Set Size (RSS) is the portion of the memory occupied by the process that is held in the main memory(RAM). The rest of the occupied memory exists in the swap space of file system, either because some parts of the occupied memory were paged out, or because some parts of the executable were never loaded.

This gives the maximum number of processes the current process may create.

This gives the maximum number of open file descriptors allowed for the current process.

This is the BSD name of RLIMIT_NOFILE.

This gives maximum address space which may be locked in the memory.

There are some more resource limit symbols used which are discussed in the next article.
Follow the link below:

More Articles of Arkaja Sharan:

Name Views Likes
Python codecs Library Error Handling schemes module functions 75 0
Python codecs Library Error Handler register_error and lookup_error functions 68 0
Python codecs Library Error Handlers 75 0
Python codecs Library open and EncodedFile functions 66 0
Python codecs Library iterencode and iterdecode functions 85 0
Python codecs Library register and unregister functions 62 0
Python codecs Library getreader and getwriter functions 77 0
Python codecs Library getincrementalencoder and getincrementaldecoder 62 0
Python codecs Library getencoder and getdecoder functions 69 0
Python Introduction to codecs Library 95 0
Python fcntl Library flock and lockf functions 76 0
Python fcntl Library fcntl and ioctl functions 87 0
Python Resource Library resource usage functions 87 0
Python Resource Library resource usage symbolic constants 71 0
Python Resource Library Resource Limit Functions 84 0
Python resource library resource limit symbolic constants 78 0
Python Introduction to Resource Library 68 0
Python stringprep Library in_table_d1 and in_table_d2 functions 75 0
Python stringprep Library in_table_c8 and in_table_c9 functions 79 0
Python stringprep Library in_table_c5 in_table_c6 and in_table_c7 functions 68 0
Python stringprep Library in_table_c3 and in_table_c4 functions 75 0
Python stringprep library in_table_c21 in_table_c22 and in_table_c21_c22 76 0
Python stringprep library functions in_table_c11 in_table_c12 and in_table_c11_c12 76 0
Python Introduction to stringprep Library 79 0
Python unicodedata library is_normalized unidata_version and ucd_3_2_0 74 0
Python Unicodedata Library functions normalize and decomposition 127 0
Python Unicodedata Library functions east_asian_width and mirrored 79 1
Python Unicodedata Library category bidirectional and combining functions 113 0
Introduction to Unicodedata library lookup and name functions 76 0
Unicode Library decimal digit and numeric functions 77 0
Introduction to Unicode Data library 0 0