[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pypy-svn
Subject:    [pypy-commit] pypy.org extradoc: Copy some documentation about ``-X track-resources`` here as well
From:       arigo <pypy.commits () gmail ! com>
Date:       2016-08-31 17:18:45
Message-ID: 57c71175.e2efc20a.1a16b.51ab () mx ! google ! com
[Download RAW message or body]

Author: Armin Rigo <arigo@tunes.org>
Branch: extradoc
Changeset: r783:097e4f70c803
Date: 2016-08-31 19:18 +0200
http://bitbucket.org/pypy/pypy.org/changeset/097e4f70c803/

Log:	Copy some documentation about ``-X track-resources`` here as well

diff --git a/compat.html b/compat.html
--- a/compat.html
+++ b/compat.html
@@ -116,6 +116,16 @@
 <div class="syntax python"><pre><span></span><span class="n">f</span> <span \
class="o">=</span> <span class="nb">open</span><span class="p">(</span><span \
class="s2">&quot;filename&quot;</span><span class="p">,</span> <span \
class="s2">&quot;w&quot;</span><span class="p">)</span><br/><span \
class="n">f</span><span class="o">.</span><span class="n">write</span><span \
class="p">(</span><span class="s2">&quot;stuff&quot;</span><span \
class="p">)</span><br/><span class="n">f</span><span class="o">.</span><span \
class="n">close</span><span class="p">()</span><br/></pre></div>  <p>or using the <tt \
class="docutils literal">with</tt> keyword</p>  <div class="syntax \
python"><pre><span></span><span class="k">with</span> <span \
class="nb">open</span><span class="p">(</span><span \
class="s2">&quot;filename&quot;</span><span class="p">,</span> <span \
class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> \
<span class="n">f</span><span class="p">:</span><br/>    <span \
class="n">f</span><span class="o">.</span><span class="n">write</span><span \
class="p">(</span><span class="s2">&quot;stuff&quot;</span><span \
class="p">)</span><br/></pre></div> +<p>The same problem&ndash;not closing your \
files&ndash;can also show up if your +program opens a large number of files without \
closing them explicitly. +In that case, you can easily hit the system limit on the \
number of file +descriptors that are allowed to be opened at the same time.</p>
+<p>Since release 5.4, PyPy can be run with the command-line option <tt \
class="docutils literal"><span class="pre">-X</span> +<span \
class="pre">track-resources</span></tt> (as in, <tt class="docutils literal">pypy \
<span class="pre">-X</span> <span class="pre">track-resources</span> \
myprogram.py</tt>). +This produces a ResourceWarning when the GC closes a non-closed \
file or +socket.  The traceback for the place where the file or socket was
+allocated is given as well, which aids finding places where <tt class="docutils \
literal">close()</tt> +is missing.</p>
 <p>Similarly, remember that you must <tt class="docutils literal">close()</tt> a \
non-exhausted  generator in order to have its pending <tt class="docutils \
literal">finally</tt> or <tt class="docutils literal">with</tt>  clauses executed \
                immediately:</p>
diff --git a/source/compat.txt b/source/compat.txt
--- a/source/compat.txt
+++ b/source/compat.txt
@@ -86,6 +86,18 @@
     with open("filename", "w") as f:
         f.write("stuff")
 
+The same problem---not closing your files---can also show up if your
+program opens a large number of files without closing them explicitly.
+In that case, you can easily hit the system limit on the number of file
+descriptors that are allowed to be opened at the same time.
+
+Since release 5.4, PyPy can be run with the command-line option ``-X
+track-resources`` (as in, ``pypy -X track-resources myprogram.py``).
+This produces a ResourceWarning when the GC closes a non-closed file or
+socket.  The traceback for the place where the file or socket was
+allocated is given as well, which aids finding places where ``close()``
+is missing.
+
 Similarly, remember that you must ``close()`` a non-exhausted
 generator in order to have its pending ``finally`` or ``with``
 clauses executed immediately:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic