⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node215.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>8.15.1 Resource Limits</title>
<META NAME="description" CONTENT="8.15.1 Resource Limits">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" HREF="node216.html" tppabs="http://www.python.org/doc/current/lib/node216.html">
<LINK REL="previous" href="module-resource.html" tppabs="http://www.python.org/doc/current/lib/module-resource.html">
<LINK REL="up" href="module-resource.html" tppabs="http://www.python.org/doc/current/lib/module-resource.html">
<LINK REL="next" HREF="node216.html" tppabs="http://www.python.org/doc/current/lib/node216.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-resource.html" tppabs="http://www.python.org/doc/current/lib/module-resource.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="module-resource.html" tppabs="http://www.python.org/doc/current/lib/module-resource.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A HREF="node216.html" tppabs="http://www.python.org/doc/current/lib/node216.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-resource.html" tppabs="http://www.python.org/doc/current/lib/module-resource.html">8.15 resource  </A>
<b class="navlabel">Up:</b> <a class="sectref" href="module-resource.html" tppabs="http://www.python.org/doc/current/lib/module-resource.html">8.15 resource  </A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node216.html" tppabs="http://www.python.org/doc/current/lib/node216.html">8.15.2 Resource Usage</A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION00101510000000000000000">
8.15.1 Resource Limits</A>
</H2>

<P>
Resources usage can be limited using the <tt class="function">setrlimit()</tt> function
described below. Each resource is controlled by a pair of limits: a
soft limit and a hard limit. The soft limit is the current limit, and
may be lowered or raised by a process over time. The soft limit can
never exceed the hard limit. The hard limit can be lowered to any
value greater than the soft limit, but not raised. (Only processes with
the effective UID of the super-user can raise a hard limit.)

<P>
The specific resources that can be limited are system dependent. They
are described in the <span class='manpage'><i>getrlimit</i>(2)</span> man page.  The resources
listed below are supported when the underlying operating system
supports them; resources which cannot be checked or controlled by the
operating system are not defined in this module for those platforms.

<P>
<dl><dt><b><a name='l2h-1903'><tt class='function'>getrlimit</tt></a></b> (<var>resource</var>)
<dd>
  Returns a tuple <code>(<var>soft</var>, <var>hard</var>)</code> with the current
  soft and hard limits of <var>resource</var>. Raises <tt class="exception">ValueError</tt> if
  an invalid resource is specified, or <tt class="exception">error</tt> if the
  underyling system call fails unexpectedly.
</dl>

<P>
<dl><dt><b><a name='l2h-1904'><tt class='function'>setrlimit</tt></a></b> (<var>resource, limits</var>)
<dd>
  Sets new limits of consumption of <var>resource</var>. The <var>limits</var>
  argument must be a tuple <code>(<var>soft</var>, <var>hard</var>)</code> of two
  integers describing the new limits. A value of <code>-1</code> can be used to
  specify the maximum possible upper limit.

<P>
Raises <tt class="exception">ValueError</tt> if an invalid resource is specified,
  if the new soft limit exceeds the hard limit, or if a process tries
  to raise its hard limit (unless the process has an effective UID of
  super-user).  Can also raise <tt class="exception">error</tt> if the underyling
  system call fails.
</dl>

<P>
These symbols define resources whose consumption can be controlled
using the <tt class="function">setrlimit()</tt> and <tt class="function">getrlimit()</tt> functions
described below. The values of these symbols are exactly the constants
used by C programs.

<P>
The Unix man page for <span class='manpage'><i>getrlimit</i>(2)</span> lists the available
resources.  Note that not all systems use the same symbol or same
value to denote the same resource.

<P>
<dl><dt><b><a name='l2h-1905'><tt>RLIMIT_CORE</tt></a></b>
<dd>
  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.
</dl>

<P>
<dl><dt><b><a name='l2h-1906'><tt>RLIMIT_CPU</tt></a></b>
<dd>
  The maximum amount of CPU time (in seconds) that a process can
  use. If this limit is exceeded, a <tt class="constant">SIGXCPU</tt> signal is sent to
  the process. (See the <tt class='module'><a href="module-signal.html" tppabs="http://www.python.org/doc/current/lib/module-signal.html">signal</a></tt> module documentation for
  information about how to catch this signal and do something useful,
  e.g. flush open files to disk.)
</dl>

<P>
<dl><dt><b><a name='l2h-1907'><tt>RLIMIT_FSIZE</tt></a></b>
<dd>
  The maximum size of a file which the process may create.  This only
  affects the stack of the main thread in a multi-threaded process.
</dl>

<P>
<dl><dt><b><a name='l2h-1908'><tt>RLIMIT_DATA</tt></a></b>
<dd>
  The maximum size (in bytes) of the process's heap.
</dl>

<P>
<dl><dt><b><a name='l2h-1909'><tt>RLIMIT_STACK</tt></a></b>
<dd>
  The maximum size (in bytes) of the call stack for the current
  process.
</dl>

<P>
<dl><dt><b><a name='l2h-1910'><tt>RLIMIT_RSS</tt></a></b>
<dd>
  The maximum resident set size that should be made available to the
  process.
</dl>

<P>
<dl><dt><b><a name='l2h-1911'><tt>RLIMIT_NPROC</tt></a></b>
<dd>
  The maximum number of processes the current process may create.
</dl>

<P>
<dl><dt><b><a name='l2h-1912'><tt>RLIMIT_NOFILE</tt></a></b>
<dd>
  The maximum number of open file descriptors for the current
  process.
</dl>

<P>
<dl><dt><b><a name='l2h-1913'><tt>RLIMIT_OFILE</tt></a></b>
<dd>
  The BSD name for <tt class="constant">RLIMIT_NOFILE</tt>.
</dl>

<P>
<dl><dt><b><a name='l2h-1914'><tt>RLIMIT_MEMLOC</tt></a></b>
<dd>
  The maximm address space which may be locked in memory.
</dl>

<P>
<dl><dt><b><a name='l2h-1915'><tt>RLIMIT_VMEM</tt></a></b>
<dd>
  The largest area of mapped memory which the process may occupy.
</dl>

<P>
<dl><dt><b><a name='l2h-1916'><tt>RLIMIT_AS</tt></a></b>
<dd>
  The maximum area (in bytes) of address space which may be taken by
  the process.
</dl>

<P>

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-resource.html" tppabs="http://www.python.org/doc/current/lib/module-resource.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="module-resource.html" tppabs="http://www.python.org/doc/current/lib/module-resource.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A HREF="node216.html" tppabs="http://www.python.org/doc/current/lib/node216.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-resource.html" tppabs="http://www.python.org/doc/current/lib/module-resource.html">8.15 resource  </A>
<b class="navlabel">Up:</b> <a class="sectref" href="module-resource.html" tppabs="http://www.python.org/doc/current/lib/module-resource.html">8.15 resource  </A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node216.html" tppabs="http://www.python.org/doc/current/lib/node216.html">8.15.2 Resource Usage</A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -