508 lines
29 KiB
HTML
508 lines
29 KiB
HTML
<!DOCTYPE html>
|
||
|
||
<html lang="en" data-content_root="../">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
<meta property="og:title" content="Command-line introspection tools" />
|
||
<meta property="og:type" content="website" />
|
||
<meta property="og:url" content="https://docs.python.org/3/library/asyncio-tools.html" />
|
||
<meta property="og:site_name" content="Python documentation" />
|
||
<meta property="og:description" content="Source code: Lib/asyncio/tools.py The asyncio module can be invoked as a script via python -m asyncio to inspect the task graph of another running Python process without modifying it or restarting ..." />
|
||
<meta property="og:image" content="_static/og-image.png" />
|
||
<meta property="og:image:alt" content="Python documentation" />
|
||
<meta name="description" content="Source code: Lib/asyncio/tools.py The asyncio module can be invoked as a script via python -m asyncio to inspect the task graph of another running Python process without modifying it or restarting ..." />
|
||
<meta name="theme-color" content="#3776ab">
|
||
<meta property="og:image:width" content="200">
|
||
<meta property="og:image:height" content="200">
|
||
|
||
<title>Command-line introspection tools — Python 3.15.0 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=48df1187" />
|
||
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=0fc419ee" />
|
||
|
||
<script src="../_static/documentation_options.js?v=0fe728b1"></script>
|
||
<script src="../_static/doctools.js?v=9bcbadda"></script>
|
||
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
|
||
|
||
<script src="../_static/sidebar.js"></script>
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml"
|
||
title="Search within Python 3.15.0 documentation"
|
||
href="../_static/opensearch.xml"/>
|
||
<link rel="author" title="About these documents" href="../about.html" />
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="copyright" title="Copyright" href="../copyright.html" />
|
||
<link rel="next" title="Event loop" href="asyncio-eventloop.html" />
|
||
<link rel="prev" title="Call graph introspection" href="asyncio-graph.html" />
|
||
|
||
|
||
<link rel="canonical" href="https://docs.python.org/3/library/asyncio-tools.html">
|
||
|
||
|
||
|
||
|
||
<style>
|
||
@media only screen {
|
||
table.full-width-table {
|
||
width: 100%;
|
||
}
|
||
}
|
||
</style>
|
||
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
|
||
<link rel="shortcut icon" type="image/png" href="../_static/py.svg">
|
||
<script type="text/javascript" src="../_static/copybutton.js"></script>
|
||
<script type="text/javascript" src="../_static/menu.js"></script>
|
||
<script type="text/javascript" src="../_static/search-focus.js"></script>
|
||
<script type="text/javascript" src="../_static/themetoggle.js"></script>
|
||
<script type="text/javascript" src="../_static/rtd_switcher.js"></script>
|
||
<meta name="readthedocs-addons-api-version" content="1">
|
||
|
||
</head>
|
||
<body>
|
||
<div class="mobile-nav">
|
||
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
|
||
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">
|
||
<nav class="nav-content" role="navigation">
|
||
<label for="menuToggler" class="toggler__label">
|
||
<span></span>
|
||
</label>
|
||
<span class="nav-items-wrapper">
|
||
<a href="https://www.python.org/" class="nav-logo">
|
||
<img src="../_static/py.svg" alt="Python logo">
|
||
</a>
|
||
<span class="version_switcher_placeholder"></span>
|
||
<form role="search" class="search" action="../search.html" method="get">
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
|
||
<path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
|
||
</svg>
|
||
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q">
|
||
<input type="submit" value="Go">
|
||
</form>
|
||
</span>
|
||
</nav>
|
||
<div class="menu-wrapper">
|
||
<nav class="menu" role="navigation" aria-label="main navigation">
|
||
<div class="language_switcher_placeholder"></div>
|
||
|
||
<label class="theme-selector-label">
|
||
Theme
|
||
<select class="theme-selector" oninput="activateTheme(this.value)">
|
||
<option value="auto" selected>Auto</option>
|
||
<option value="light">Light</option>
|
||
<option value="dark">Dark</option>
|
||
</select>
|
||
</label>
|
||
<div>
|
||
<h3><a href="../contents.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">Command-line introspection tools</a><ul>
|
||
<li><a class="reference internal" href="#command-line-options">Command-line options</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
</div>
|
||
<div>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="asyncio-graph.html"
|
||
title="previous chapter">Call graph introspection</a></p>
|
||
</div>
|
||
<div>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="asyncio-eventloop.html"
|
||
title="next chapter">Event loop</a></p>
|
||
</div>
|
||
<script>
|
||
document.addEventListener('DOMContentLoaded', () => {
|
||
const title = document.querySelector('meta[property="og:title"]').content;
|
||
const elements = document.querySelectorAll('.improvepage');
|
||
const pageurl = window.location.href.split('?')[0];
|
||
elements.forEach(element => {
|
||
const url = new URL(element.href.split('?')[0].replace("-nojs", ""));
|
||
url.searchParams.set('pagetitle', title);
|
||
url.searchParams.set('pageurl', pageurl);
|
||
url.searchParams.set('pagesource', "library/asyncio-tools.rst");
|
||
element.href = url.toString();
|
||
});
|
||
});
|
||
</script>
|
||
<div role="note" aria-label="source link">
|
||
<h3>This page</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">Report a bug</a></li>
|
||
<li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.15/Doc/library/asyncio-tools.rst?plain=1"
|
||
rel="nofollow">Show source
|
||
</a>
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="asyncio-eventloop.html" title="Event loop"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="asyncio-graph.html" title="Call graph introspection"
|
||
accesskey="P">previous</a> |</li>
|
||
|
||
<li class="root-icon"><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.15.0 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >The Python standard library</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="ipc.html" >Networking and Interprocess Communication</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="asyncio.html" accesskey="U"><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code> — Asynchronous I/O</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">Command-line introspection tools</a></li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">
|
||
<input type="submit" value="Go">
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
<li class="right">
|
||
<label class="theme-selector-label">
|
||
Theme
|
||
<select class="theme-selector" oninput="activateTheme(this.value)">
|
||
<option value="auto" selected>Auto</option>
|
||
<option value="light">Light</option>
|
||
<option value="dark">Dark</option>
|
||
</select>
|
||
</label> |</li>
|
||
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="command-line-introspection-tools">
|
||
<span id="asyncio-introspection-tools"></span><h1>Command-line introspection tools<a class="headerlink" href="#command-line-introspection-tools" title="Link to this heading">¶</a></h1>
|
||
<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/3.15/Lib/asyncio/tools.py">Lib/asyncio/tools.py</a></p>
|
||
<hr class="docutils" />
|
||
<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code> module can be invoked as a script via <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span>
|
||
<span class="pre">asyncio</span></code> to inspect the task graph of another running Python process without
|
||
modifying it or restarting it. The <code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio.tools</span></code> submodule implements
|
||
this interface.</p>
|
||
<p>The following commands inspect the process identified by <code class="docutils literal notranslate"><span class="pre">PID</span></code>:</p>
|
||
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>python<span class="w"> </span>-m<span class="w"> </span>asyncio<span class="w"> </span>pstree<span class="w"> </span><span class="o">[</span>--retries<span class="w"> </span>N<span class="o">]</span><span class="w"> </span>PID
|
||
<span class="gp">$ </span>python<span class="w"> </span>-m<span class="w"> </span>asyncio<span class="w"> </span>ps<span class="w"> </span><span class="o">[</span>--retries<span class="w"> </span>N<span class="o">]</span><span class="w"> </span>PID
|
||
</pre></div>
|
||
</div>
|
||
<p>The commands read the target process state without executing any code in it.
|
||
They are only available on supported platforms and may require permission to
|
||
inspect another process. See the <a class="reference internal" href="../howto/remote_debugging.html#permission-requirements"><span class="std std-ref">permission requirements</span></a> for details.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<dl class="simple">
|
||
<dt><a class="reference internal" href="asyncio-graph.html#asyncio-graph"><span class="std std-ref">Call graph introspection</span></a></dt><dd><p>Programmatic APIs for inspecting the async call graph of a task or
|
||
future in the current process.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<p>The command examples below use this program, which creates a task hierarchy
|
||
suitable for inspection and prints its process ID:</p>
|
||
<div class="literal-block-wrapper docutils container" id="id1">
|
||
<div class="code-block-caption"><span class="caption-text">example.py</span><a class="headerlink" href="#id1" title="Link to this code">¶</a></div>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">asyncio</span>
|
||
<span class="kn">import</span><span class="w"> </span><span class="nn">os</span>
|
||
|
||
<span class="k">async</span> <span class="k">def</span><span class="w"> </span><span class="nf">play</span><span class="p">(</span><span class="n">track</span><span class="p">):</span>
|
||
<span class="k">await</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">3600</span><span class="p">)</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"🎵 Finished: </span><span class="si">{</span><span class="n">track</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
|
||
<span class="k">async</span> <span class="k">def</span><span class="w"> </span><span class="nf">album</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">tracks</span><span class="p">):</span>
|
||
<span class="k">async</span> <span class="k">with</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">TaskGroup</span><span class="p">()</span> <span class="k">as</span> <span class="n">tg</span><span class="p">:</span>
|
||
<span class="k">for</span> <span class="n">track</span> <span class="ow">in</span> <span class="n">tracks</span><span class="p">:</span>
|
||
<span class="n">tg</span><span class="o">.</span><span class="n">create_task</span><span class="p">(</span><span class="n">play</span><span class="p">(</span><span class="n">track</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="n">track</span><span class="p">)</span>
|
||
|
||
<span class="k">async</span> <span class="k">def</span><span class="w"> </span><span class="nf">main</span><span class="p">():</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"PID: </span><span class="si">{</span><span class="n">os</span><span class="o">.</span><span class="n">getpid</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||
<span class="k">async</span> <span class="k">with</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">TaskGroup</span><span class="p">()</span> <span class="k">as</span> <span class="n">tg</span><span class="p">:</span>
|
||
<span class="n">tg</span><span class="o">.</span><span class="n">create_task</span><span class="p">(</span>
|
||
<span class="n">album</span><span class="p">(</span><span class="s2">"Sundowning"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"TNDNBTG"</span><span class="p">,</span> <span class="s2">"Levitate"</span><span class="p">]),</span>
|
||
<span class="n">name</span><span class="o">=</span><span class="s2">"Sundowning"</span><span class="p">,</span>
|
||
<span class="p">)</span>
|
||
<span class="n">tg</span><span class="o">.</span><span class="n">create_task</span><span class="p">(</span>
|
||
<span class="n">album</span><span class="p">(</span><span class="s2">"TMBTE"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"DYWTYLM"</span><span class="p">,</span> <span class="s2">"Aqua Regia"</span><span class="p">]),</span>
|
||
<span class="n">name</span><span class="o">=</span><span class="s2">"TMBTE"</span><span class="p">,</span>
|
||
<span class="p">)</span>
|
||
|
||
<span class="n">asyncio</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">main</span><span class="p">())</span>
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
<p>Run the program in one terminal and leave it running:</p>
|
||
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>python<span class="w"> </span>example.py
|
||
<span class="go">PID: 12345</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Then pass the printed process ID to the commands from another terminal.
|
||
Thread IDs, task IDs, file paths, and line numbers vary between runs and
|
||
source layouts.</p>
|
||
<div class="versionadded">
|
||
<p><span class="versionmodified added">Added in version 3.14.</span></p>
|
||
</div>
|
||
<section id="command-line-options">
|
||
<h2>Command-line options<a class="headerlink" href="#command-line-options" title="Link to this heading">¶</a></h2>
|
||
<dl class="std option">
|
||
<dt class="sig sig-object std" id="cmdoption-arg-pstree">
|
||
<span class="sig-name descname"><span class="pre">pstree</span></span><span class="sig-prename descclassname"> <span class="pre">PID</span></span><a class="headerlink" href="#cmdoption-arg-pstree" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Display task and coroutine relationships as a tree. Each task is shown
|
||
with its full coroutine stack, nested under the task (if any) that is
|
||
awaiting it. This subcommand is useful for quickly identifying which branch
|
||
of a task hierarchy is blocked and where in its coroutine stack execution
|
||
has paused:</p>
|
||
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>python<span class="w"> </span>-m<span class="w"> </span>asyncio<span class="w"> </span>pstree<span class="w"> </span><span class="m">12345</span>
|
||
<span class="go">└── (T) Task-1</span>
|
||
<span class="go"> └── main example.py:12</span>
|
||
<span class="go"> └── TaskGroup.__aexit__ Lib/asyncio/taskgroups.py:75</span>
|
||
<span class="go"> └── TaskGroup._aexit Lib/asyncio/taskgroups.py:124</span>
|
||
<span class="go"> ├── (T) Sundowning</span>
|
||
<span class="go"> │ └── album example.py:7</span>
|
||
<span class="go"> │ └── TaskGroup.__aexit__ Lib/asyncio/taskgroups.py:75</span>
|
||
<span class="go"> │ └── TaskGroup._aexit Lib/asyncio/taskgroups.py:124</span>
|
||
<span class="go"> │ ├── (T) TNDNBTG</span>
|
||
<span class="go"> │ │ └── play example.py:4</span>
|
||
<span class="go"> │ │ └── sleep Lib/asyncio/tasks.py:702</span>
|
||
<span class="go"> │ └── (T) Levitate</span>
|
||
<span class="go"> │ └── play example.py:4</span>
|
||
<span class="go"> │ └── sleep Lib/asyncio/tasks.py:702</span>
|
||
<span class="go"> └── (T) TMBTE</span>
|
||
<span class="go"> └── album example.py:7</span>
|
||
<span class="go"> └── TaskGroup.__aexit__ Lib/asyncio/taskgroups.py:75</span>
|
||
<span class="go"> └── TaskGroup._aexit Lib/asyncio/taskgroups.py:124</span>
|
||
<span class="go"> ├── (T) DYWTYLM</span>
|
||
<span class="go"> │ └── play example.py:4</span>
|
||
<span class="go"> │ └── sleep Lib/asyncio/tasks.py:702</span>
|
||
<span class="go"> └── (T) Aqua Regia</span>
|
||
<span class="go"> └── play example.py:4</span>
|
||
<span class="go"> └── sleep Lib/asyncio/tasks.py:702</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>If the await graph contains a cycle, <code class="docutils literal notranslate"><span class="pre">pstree</span></code> reports an error instead
|
||
of printing a tree. A cycle in the await graph is unusual and typically
|
||
indicates a programming error:</p>
|
||
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>python<span class="w"> </span>-m<span class="w"> </span>asyncio<span class="w"> </span>pstree<span class="w"> </span><span class="m">12345</span>
|
||
<span class="go">ERROR: await-graph contains cycles - cannot print a tree!</span>
|
||
|
||
<span class="go">cycle: Task-2 → Task-3 → Task-2</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="std option">
|
||
<dt class="sig sig-object std" id="cmdoption-arg-ps">
|
||
<span class="sig-name descname"><span class="pre">ps</span></span><span class="sig-prename descclassname"> <span class="pre">PID</span></span><a class="headerlink" href="#cmdoption-arg-ps" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Display a flat table of all pending tasks in the process <em>PID</em>. Each row
|
||
shows the event-loop thread ID, task ID and name, coroutine stack, and the
|
||
awaiting task’s stack, name, and ID, if any.</p>
|
||
<p>This subcommand prints all tasks regardless of whether the await graph
|
||
contains cycles:</p>
|
||
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>python<span class="w"> </span>-m<span class="w"> </span>asyncio<span class="w"> </span>ps<span class="w"> </span><span class="m">12345</span>
|
||
<span class="go">tid task id task name coroutine stack awaiter chain awaiter name awaiter id</span>
|
||
<span class="go">------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
|
||
<span class="go">18445801 0x10a456060 Task-1 TaskGroup._aexit -> TaskGroup.__aexit__ -> main 0x0</span>
|
||
<span class="go">18445801 0x10a439f60 Sundowning TaskGroup._aexit -> TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> main Task-1 0x10a456060</span>
|
||
<span class="go">18445801 0x10a439d70 TMBTE TaskGroup._aexit -> TaskGroup.__aexit__ -> album TaskGroup._aexit -> TaskGroup.__aexit__ -> main Task-1 0x10a456060</span>
|
||
<span class="go">18445801 0x10a2a3a80 TNDNBTG sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album Sundowning 0x10a439f60</span>
|
||
<span class="go">18445801 0x10a2a38a0 Levitate sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album Sundowning 0x10a439f60</span>
|
||
<span class="go">18445801 0x10a2d7150 DYWTYLM sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album TMBTE 0x10a439d70</span>
|
||
<span class="go">18445801 0x10a6bdaa0 Aqua Regia sleep -> play TaskGroup._aexit -> TaskGroup.__aexit__ -> album TMBTE 0x10a439d70</span>
|
||
</pre></div>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
<dl class="std option">
|
||
<dt class="sig sig-object std" id="cmdoption-retries">
|
||
<span class="sig-name descname"><span class="pre">--retries</span></span><span class="sig-prename descclassname"> <span class="pre">N</span></span><a class="headerlink" href="#cmdoption-retries" title="Link to this definition">¶</a></dt>
|
||
<dd><p>Retry failed attempts to inspect the target process up to <em>N</em> times. This
|
||
can help when the target process changes while its state is being read.</p>
|
||
<div class="versionadded">
|
||
<p><span class="versionmodified added">Added in version 3.15.</span></p>
|
||
</div>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
</section>
|
||
|
||
|
||
<div class="clearer"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="Main">
|
||
<div class="sphinxsidebarwrapper">
|
||
<div>
|
||
<h3><a href="../contents.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">Command-line introspection tools</a><ul>
|
||
<li><a class="reference internal" href="#command-line-options">Command-line options</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
</div>
|
||
<div>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="asyncio-graph.html"
|
||
title="previous chapter">Call graph introspection</a></p>
|
||
</div>
|
||
<div>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="asyncio-eventloop.html"
|
||
title="next chapter">Event loop</a></p>
|
||
</div>
|
||
<script>
|
||
document.addEventListener('DOMContentLoaded', () => {
|
||
const title = document.querySelector('meta[property="og:title"]').content;
|
||
const elements = document.querySelectorAll('.improvepage');
|
||
const pageurl = window.location.href.split('?')[0];
|
||
elements.forEach(element => {
|
||
const url = new URL(element.href.split('?')[0].replace("-nojs", ""));
|
||
url.searchParams.set('pagetitle', title);
|
||
url.searchParams.set('pageurl', pageurl);
|
||
url.searchParams.set('pagesource', "library/asyncio-tools.rst");
|
||
element.href = url.toString();
|
||
});
|
||
});
|
||
</script>
|
||
<div role="note" aria-label="source link">
|
||
<h3>This page</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">Report a bug</a></li>
|
||
<li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.15/Doc/library/asyncio-tools.rst?plain=1"
|
||
rel="nofollow">Show source
|
||
</a>
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div id="sidebarbutton" title="Collapse sidebar">
|
||
<span>«</span>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="asyncio-eventloop.html" title="Event loop"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="asyncio-graph.html" title="Call graph introspection"
|
||
>previous</a> |</li>
|
||
|
||
<li class="root-icon"><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.15.0 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >The Python standard library</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="ipc.html" >Networking and Interprocess Communication</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="asyncio.html" ><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code> — Asynchronous I/O</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">Command-line introspection tools</a></li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">
|
||
<input type="submit" value="Go">
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
<li class="right">
|
||
<label class="theme-selector-label">
|
||
Theme
|
||
<select class="theme-selector" oninput="activateTheme(this.value)">
|
||
<option value="auto" selected>Auto</option>
|
||
<option value="light">Light</option>
|
||
<option value="dark">Dark</option>
|
||
</select>
|
||
</label> |</li>
|
||
|
||
</ul>
|
||
</div>
|
||
<div class="footer">
|
||
© <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.
|
||
<br>
|
||
This page is licensed under the Python Software Foundation License Version 2.
|
||
<br>
|
||
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
|
||
<br>
|
||
|
||
See <a href="/license.html">History and License</a> for more information.<br>
|
||
|
||
|
||
<br>
|
||
|
||
The Python Software Foundation is a non-profit corporation.
|
||
<a href="https://www.python.org/psf/donations/">Please donate.</a>
|
||
<br>
|
||
<br>
|
||
Last updated on Oct 09, 2026 (11:35 UTC).
|
||
|
||
<a href="/bugs.html">Found a bug</a>?
|
||
|
||
<br>
|
||
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
|
||
</div>
|
||
|
||
</body>
|
||
</html> |