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 52 0
Python codecs Library Error Handler register_error and lookup_error functions 51 0
Python codecs Library Error Handlers 50 0
Python codecs Library open and EncodedFile functions 48 0
Python codecs Library iterencode and iterdecode functions 53 0
Python codecs Library register and unregister functions 44 0
Python codecs Library getreader and getwriter functions 51 0
Python codecs Library getincrementalencoder and getincrementaldecoder 42 0
Python codecs Library getencoder and getdecoder functions 47 0
Python Introduction to codecs Library 68 0
Python fcntl Library flock and lockf functions 49 0
Python fcntl Library fcntl and ioctl functions 66 0
Python Resource Library resource usage functions 64 0
Python Resource Library resource usage symbolic constants 52 0
Python Resource Library Resource Limit Functions 61 0
Python resource library resource limit symbolic constants 58 0
Python Introduction to Resource Library 45 0
Python stringprep Library in_table_d1 and in_table_d2 functions 50 0
Python stringprep Library in_table_c8 and in_table_c9 functions 57 0
Python stringprep Library in_table_c5 in_table_c6 and in_table_c7 functions 47 0
Python stringprep Library in_table_c3 and in_table_c4 functions 50 0
Python stringprep library in_table_c21 in_table_c22 and in_table_c21_c22 44 0
Python stringprep library functions in_table_c11 in_table_c12 and in_table_c11_c12 53 0
Python Introduction to stringprep Library 53 0
Python unicodedata library is_normalized unidata_version and ucd_3_2_0 52 0
Python Unicodedata Library functions normalize and decomposition 101 0
Python Unicodedata Library functions east_asian_width and mirrored 53 1
Python Unicodedata Library category bidirectional and combining functions 87 0
Introduction to Unicodedata library lookup and name functions 51 0
Unicode Library decimal digit and numeric functions 55 0
Introduction to Unicode Data library 0 0