Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="node442.html" /> | |
13 | <link rel="prev" href="module-resource.html" /> | |
14 | <link rel="parent" href="module-resource.html" /> | |
15 | <link rel="next" href="node442.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>8.14.1 Resource Limits</title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="8.14 resource " | |
25 | href="module-resource.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="8.14 resource " | |
28 | href="module-resource.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="8.14.2 Resource Usage" | |
31 | href="node442.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Python Library Reference</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="module-resource.html">8.14 resource </A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="module-resource.html">8.14 resource </A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="node442.html">8.14.2 Resource Usage</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H2><A NAME="SECTION00101410000000000000000"> | |
56 | 8.14.1 Resource Limits</A> | |
57 | </H2> | |
58 | ||
59 | <P> | |
60 | Resources usage can be limited using the <tt class="function">setrlimit()</tt> function | |
61 | described below. Each resource is controlled by a pair of limits: a | |
62 | soft limit and a hard limit. The soft limit is the current limit, and | |
63 | may be lowered or raised by a process over time. The soft limit can | |
64 | never exceed the hard limit. The hard limit can be lowered to any | |
65 | value greater than the soft limit, but not raised. (Only processes with | |
66 | the effective UID of the super-user can raise a hard limit.) | |
67 | ||
68 | <P> | |
69 | The specific resources that can be limited are system dependent. They | |
70 | are described in the <span class="manpage"><i>getrlimit</i>(2)</span> man page. The resources | |
71 | listed below are supported when the underlying operating system | |
72 | supports them; resources which cannot be checked or controlled by the | |
73 | operating system are not defined in this module for those platforms. | |
74 | ||
75 | <P> | |
76 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
77 | <td><nobr><b><tt id='l2h-3057' xml:id='l2h-3057' class="function">getrlimit</tt></b>(</nobr></td> | |
78 | <td><var>resource</var>)</td></tr></table></dt> | |
79 | <dd> | |
80 | Returns a tuple <code>(<var>soft</var>, <var>hard</var>)</code> with the current | |
81 | soft and hard limits of <var>resource</var>. Raises <tt class="exception">ValueError</tt> if | |
82 | an invalid resource is specified, or <tt class="exception">error</tt> if the | |
83 | underlying system call fails unexpectedly. | |
84 | </dl> | |
85 | ||
86 | <P> | |
87 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
88 | <td><nobr><b><tt id='l2h-3058' xml:id='l2h-3058' class="function">setrlimit</tt></b>(</nobr></td> | |
89 | <td><var>resource, limits</var>)</td></tr></table></dt> | |
90 | <dd> | |
91 | Sets new limits of consumption of <var>resource</var>. The <var>limits</var> | |
92 | argument must be a tuple <code>(<var>soft</var>, <var>hard</var>)</code> of two | |
93 | integers describing the new limits. A value of <code>-1</code> can be used to | |
94 | specify the maximum possible upper limit. | |
95 | ||
96 | <P> | |
97 | Raises <tt class="exception">ValueError</tt> if an invalid resource is specified, | |
98 | if the new soft limit exceeds the hard limit, or if a process tries | |
99 | to raise its hard limit (unless the process has an effective UID of | |
100 | super-user). Can also raise <tt class="exception">error</tt> if the underlying | |
101 | system call fails. | |
102 | </dl> | |
103 | ||
104 | <P> | |
105 | These symbols define resources whose consumption can be controlled | |
106 | using the <tt class="function">setrlimit()</tt> and <tt class="function">getrlimit()</tt> functions | |
107 | described below. The values of these symbols are exactly the constants | |
108 | used by C programs. | |
109 | ||
110 | <P> | |
111 | The <span class="Unix">Unix</span> man page for <span class="manpage"><i>getrlimit</i>(2)</span> lists the available | |
112 | resources. Note that not all systems use the same symbol or same | |
113 | value to denote the same resource. This module does not attempt to | |
114 | mask platform differences -- symbols not defined for a platform will | |
115 | not be available from this module on that platform. | |
116 | ||
117 | <P> | |
118 | <dl><dt><b><tt id='l2h-3059' xml:id='l2h-3059'>RLIMIT_CORE</tt></b></dt> | |
119 | <dd> | |
120 | The maximum size (in bytes) of a core file that the current process | |
121 | can create. This may result in the creation of a partial core file | |
122 | if a larger core would be required to contain the entire process | |
123 | image. | |
124 | </dd></dl> | |
125 | ||
126 | <P> | |
127 | <dl><dt><b><tt id='l2h-3060' xml:id='l2h-3060'>RLIMIT_CPU</tt></b></dt> | |
128 | <dd> | |
129 | The maximum amount of processor time (in seconds) that a process can | |
130 | use. If this limit is exceeded, a <tt class="constant">SIGXCPU</tt> signal is sent to | |
131 | the process. (See the <tt class="module"><a href="module-signal.html">signal</a></tt> module documentation for | |
132 | information about how to catch this signal and do something useful, | |
133 | e.g. flush open files to disk.) | |
134 | </dd></dl> | |
135 | ||
136 | <P> | |
137 | <dl><dt><b><tt id='l2h-3061' xml:id='l2h-3061'>RLIMIT_FSIZE</tt></b></dt> | |
138 | <dd> | |
139 | The maximum size of a file which the process may create. This only | |
140 | affects the stack of the main thread in a multi-threaded process. | |
141 | </dd></dl> | |
142 | ||
143 | <P> | |
144 | <dl><dt><b><tt id='l2h-3062' xml:id='l2h-3062'>RLIMIT_DATA</tt></b></dt> | |
145 | <dd> | |
146 | The maximum size (in bytes) of the process's heap. | |
147 | </dd></dl> | |
148 | ||
149 | <P> | |
150 | <dl><dt><b><tt id='l2h-3063' xml:id='l2h-3063'>RLIMIT_STACK</tt></b></dt> | |
151 | <dd> | |
152 | The maximum size (in bytes) of the call stack for the current | |
153 | process. | |
154 | </dd></dl> | |
155 | ||
156 | <P> | |
157 | <dl><dt><b><tt id='l2h-3064' xml:id='l2h-3064'>RLIMIT_RSS</tt></b></dt> | |
158 | <dd> | |
159 | The maximum resident set size that should be made available to the | |
160 | process. | |
161 | </dd></dl> | |
162 | ||
163 | <P> | |
164 | <dl><dt><b><tt id='l2h-3065' xml:id='l2h-3065'>RLIMIT_NPROC</tt></b></dt> | |
165 | <dd> | |
166 | The maximum number of processes the current process may create. | |
167 | </dd></dl> | |
168 | ||
169 | <P> | |
170 | <dl><dt><b><tt id='l2h-3066' xml:id='l2h-3066'>RLIMIT_NOFILE</tt></b></dt> | |
171 | <dd> | |
172 | The maximum number of open file descriptors for the current | |
173 | process. | |
174 | </dd></dl> | |
175 | ||
176 | <P> | |
177 | <dl><dt><b><tt id='l2h-3067' xml:id='l2h-3067'>RLIMIT_OFILE</tt></b></dt> | |
178 | <dd> | |
179 | The BSD name for <tt class="constant">RLIMIT_NOFILE</tt>. | |
180 | </dd></dl> | |
181 | ||
182 | <P> | |
183 | <dl><dt><b><tt id='l2h-3068' xml:id='l2h-3068'>RLIMIT_MEMLOCK</tt></b></dt> | |
184 | <dd> | |
185 | The maximum address space which may be locked in memory. | |
186 | </dd></dl> | |
187 | ||
188 | <P> | |
189 | <dl><dt><b><tt id='l2h-3069' xml:id='l2h-3069'>RLIMIT_VMEM</tt></b></dt> | |
190 | <dd> | |
191 | The largest area of mapped memory which the process may occupy. | |
192 | </dd></dl> | |
193 | ||
194 | <P> | |
195 | <dl><dt><b><tt id='l2h-3070' xml:id='l2h-3070'>RLIMIT_AS</tt></b></dt> | |
196 | <dd> | |
197 | The maximum area (in bytes) of address space which may be taken by | |
198 | the process. | |
199 | </dd></dl> | |
200 | ||
201 | <P> | |
202 | ||
203 | <DIV CLASS="navigation"> | |
204 | <div class='online-navigation'> | |
205 | <p></p><hr /> | |
206 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
207 | <tr> | |
208 | <td class='online-navigation'><a rel="prev" title="8.14 resource " | |
209 | href="module-resource.html"><img src='../icons/previous.png' | |
210 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
211 | <td class='online-navigation'><a rel="parent" title="8.14 resource " | |
212 | href="module-resource.html"><img src='../icons/up.png' | |
213 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
214 | <td class='online-navigation'><a rel="next" title="8.14.2 Resource Usage" | |
215 | href="node442.html"><img src='../icons/next.png' | |
216 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
217 | <td align="center" width="100%">Python Library Reference</td> | |
218 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
219 | href="contents.html"><img src='../icons/contents.png' | |
220 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
221 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
222 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
223 | <td class='online-navigation'><a rel="index" title="Index" | |
224 | href="genindex.html"><img src='../icons/index.png' | |
225 | border='0' height='32' alt='Index' width='32' /></A></td> | |
226 | </tr></table> | |
227 | <div class='online-navigation'> | |
228 | <b class="navlabel">Previous:</b> | |
229 | <a class="sectref" rel="prev" href="module-resource.html">8.14 resource </A> | |
230 | <b class="navlabel">Up:</b> | |
231 | <a class="sectref" rel="parent" href="module-resource.html">8.14 resource </A> | |
232 | <b class="navlabel">Next:</b> | |
233 | <a class="sectref" rel="next" href="node442.html">8.14.2 Resource Usage</A> | |
234 | </div> | |
235 | </div> | |
236 | <hr /> | |
237 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
238 | </DIV> | |
239 | <!--End of Navigation Panel--> | |
240 | <ADDRESS> | |
241 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
242 | </ADDRESS> | |
243 | </BODY> | |
244 | </HTML> |