parthtamu/rag-code-assistant
0
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4 <head>5 <meta charset="utf-8" />6 <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="select — Waiting for I/O completion" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/select.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="This module provides access to the select() and poll() functions available in most operating systems, devpoll() available on Solaris and derivatives, epoll() available on Linux 2.5+ and kqueue() av..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_select_179f1351.png" />15<meta property="og:image:alt" content="This module provides access to the select() and poll() functions available in most operating systems, devpoll() available on Solaris and derivatives, epoll() available on Linux 2.5+ and kqueue() av..." />16<meta name="description" content="This module provides access to the select() and poll() functions available in most operating systems, devpoll() available on Solaris and derivatives, epoll() available on Linux 2.5+ and kqueue() av..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20 <title>select — Waiting for I/O completion — Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21 22 <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23 <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24 <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25 <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26 <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27 28 <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29 <script src="../_static/doctools.js?v=9bcbadda"></script>30 <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31 <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32 33 <script src="../_static/sidebar.js"></script>34 35 <link rel="search" type="application/opensearchdescription+xml"36 title="Search within Python 3.15.0a6 documentation"37 href="../_static/opensearch.xml"/>38 <link rel="author" title="About these documents" href="../about.html" />39 <link rel="index" title="Index" href="../genindex.html" />40 <link rel="search" title="Search" href="../search.html" />41 <link rel="copyright" title="Copyright" href="../copyright.html" />42 <link rel="next" title="selectors — High-level I/O multiplexing" href="selectors.html" />43 <link rel="prev" title="ssl — TLS/SSL wrapper for socket objects" href="ssl.html" />44 45 46 <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47 48 <link rel="canonical" href="https://docs.python.org/3/library/select.html">49 50 51 52 53 <style>54 @media only screen {55 table.full-width-table {56 width: 100%;57 }58 }59 </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61 <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62 <script type="text/javascript" src="../_static/copybutton.js"></script>63 <script type="text/javascript" src="../_static/menu.js"></script>64 <script type="text/javascript" src="../_static/search-focus.js"></script>65 <script type="text/javascript" src="../_static/themetoggle.js"></script> 66 <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67 <meta name="readthedocs-addons-api-version" content="1">68 69 </head>70<body>71<div class="mobile-nav">72 <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73 aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74 <nav class="nav-content" role="navigation">75 <label for="menuToggler" class="toggler__label">76 <span></span>77 </label>78 <span class="nav-items-wrapper">79 <a href="https://www.python.org/" class="nav-logo">80 <img src="../_static/py.svg" alt="Python logo">81 </a>82 <span class="version_switcher_placeholder"></span>83 <form role="search" class="search" action="../search.html" method="get">84 <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85 <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>86 </svg>87 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88 <input type="submit" value="Go">89 </form>90 </span>91 </nav>92 <div class="menu-wrapper">93 <nav class="menu" role="navigation" aria-label="main navigation">94 <div class="language_switcher_placeholder"></div>95 96<label class="theme-selector-label">97 Theme98 <select class="theme-selector" oninput="activateTheme(this.value)">99 <option value="auto" selected>Auto</option>100 <option value="light">Light</option>101 <option value="dark">Dark</option>102 </select>103</label>104 <div>105 <h3><a href="../contents.html">Table of Contents</a></h3>106 <ul>107<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">select</span></code> — Waiting for I/O completion</a><ul>108<li><a class="reference internal" href="#dev-poll-polling-objects"><code class="docutils literal notranslate"><span class="pre">/dev/poll</span></code> Polling Objects</a></li>109<li><a class="reference internal" href="#edge-and-level-trigger-polling-epoll-objects">Edge and Level Trigger Polling (epoll) Objects</a></li>110<li><a class="reference internal" href="#polling-objects">Polling Objects</a></li>111<li><a class="reference internal" href="#kqueue-objects">Kqueue Objects</a></li>112<li><a class="reference internal" href="#kevent-objects">Kevent Objects</a></li>113</ul>114</li>115</ul>116 117 </div>118 <div>119 <h4>Previous topic</h4>120 <p class="topless"><a href="ssl.html"121 title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code> — TLS/SSL wrapper for socket objects</a></p>122 </div>123 <div>124 <h4>Next topic</h4>125 <p class="topless"><a href="selectors.html"126 title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">selectors</span></code> — High-level I/O multiplexing</a></p>127 </div>128 <script>129 document.addEventListener('DOMContentLoaded', () => {130 const title = document.querySelector('meta[property="og:title"]').content;131 const elements = document.querySelectorAll('.improvepage');132 const pageurl = window.location.href.split('?')[0];133 elements.forEach(element => {134 const url = new URL(element.href.split('?')[0].replace("-nojs", ""));135 url.searchParams.set('pagetitle', title);136 url.searchParams.set('pageurl', pageurl);137 url.searchParams.set('pagesource', "library/select.rst");138 element.href = url.toString();139 });140 });141 </script>142 <div role="note" aria-label="source link">143 <h3>This page</h3>144 <ul class="this-page-menu">145 <li><a href="../bugs.html">Report a bug</a></li>146 <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>147 <li>148 <a href="https://github.com/python/cpython/blob/main/Doc/library/select.rst?plain=1"149 rel="nofollow">Show source150 </a>151 </li>152 153 </ul>154 </div>155 </nav>156 </div>157</div>158 159 160 <div class="related" role="navigation" aria-label="Related">161 <h3>Navigation</h3>162 <ul>163 <li class="right" style="margin-right: 10px">164 <a href="../genindex.html" title="General Index"165 accesskey="I">index</a></li>166 <li class="right" >167 <a href="../py-modindex.html" title="Python Module Index"168 >modules</a> |</li>169 <li class="right" >170 <a href="selectors.html" title="selectors — High-level I/O multiplexing"171 accesskey="N">next</a> |</li>172 <li class="right" >173 <a href="ssl.html" title="ssl — TLS/SSL wrapper for socket objects"174 accesskey="P">previous</a> |</li>175 176 <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>177 <li><a href="https://www.python.org/">Python</a> »</li>178 <li class="switchers">179 <div class="language_switcher_placeholder"></div>180 <div class="version_switcher_placeholder"></div>181 </li>182 <li>183 184 </li>185 <li id="cpython-language-and-version">186 <a href="../index.html">3.15.0a6 Documentation</a> »187 </li>188 189 <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>190 <li class="nav-item nav-item-2"><a href="ipc.html" accesskey="U">Networking and Interprocess Communication</a> »</li>191 <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">select</span></code> — Waiting for I/O completion</a></li>192 <li class="right">193 194 195 <div class="inline-search" role="search">196 <form class="inline-search" action="../search.html" method="get">197 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">198 <input type="submit" value="Go">199 </form>200 </div>201 |202 </li>203 <li class="right">204<label class="theme-selector-label">205 Theme206 <select class="theme-selector" oninput="activateTheme(this.value)">207 <option value="auto" selected>Auto</option>208 <option value="light">Light</option>209 <option value="dark">Dark</option>210 </select>211</label> |</li>212 213 </ul>214 </div> 215 216 <div class="document">217 <div class="documentwrapper">218 <div class="bodywrapper">219 <div class="body" role="main">220 221 <section id="module-select">222<span id="select-waiting-for-i-o-completion"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">select</span></code> — Waiting for I/O completion<a class="headerlink" href="#module-select" title="Link to this heading">¶</a></h1>223<hr class="docutils" />224<p>This module provides access to the <code class="xref c c-func docutils literal notranslate"><span class="pre">select()</span></code> and <code class="xref c c-func docutils literal notranslate"><span class="pre">poll()</span></code> functions225available in most operating systems, <code class="xref c c-func docutils literal notranslate"><span class="pre">devpoll()</span></code> available on226Solaris and derivatives, <code class="xref c c-func docutils literal notranslate"><span class="pre">epoll()</span></code> available on Linux 2.5+ and227<code class="xref c c-func docutils literal notranslate"><span class="pre">kqueue()</span></code> available on most BSD.228Note that on Windows, it only works for sockets; on other operating systems,229it also works for other file types (in particular, on Unix, it works on pipes).230It cannot be used on regular files to determine whether a file has grown since231it was last read.</p>232<div class="admonition note">233<p class="admonition-title">Note</p>234<p>The <a class="reference internal" href="selectors.html#module-selectors" title="selectors: High-level I/O multiplexing."><code class="xref py py-mod docutils literal notranslate"><span class="pre">selectors</span></code></a> module allows high-level and efficient I/O235multiplexing, built upon the <code class="xref py py-mod docutils literal notranslate"><span class="pre">select</span></code> module primitives. Users are236encouraged to use the <code class="xref py py-mod docutils literal notranslate"><span class="pre">selectors</span></code> module instead, unless they want237precise control over the OS-level primitives used.</p>238</div>239<div class="availability docutils container">240<p><a class="reference internal" href="intro.html#availability"><span class="std std-ref">Availability</span></a>: not WASI.</p>241<p>This module does not work or is not available on WebAssembly. See242<a class="reference internal" href="intro.html#wasm-availability"><span class="std std-ref">WebAssembly platforms</span></a> for more information.</p>243</div>244<p>The module defines the following:</p>245<dl class="py exception">246<dt class="sig sig-object py" id="select.error">247<em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">select.</span></span><span class="sig-name descname"><span class="pre">error</span></span><a class="headerlink" href="#select.error" title="Link to this definition">¶</a></dt>248<dd><p>A deprecated alias of <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>.</p>249<div class="versionchanged">250<p><span class="versionmodified changed">Changed in version 3.3: </span>Following <span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-3151/"><strong>PEP 3151</strong></a>, this class was made an alias of <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>.</p>251</div>252</dd></dl>253 254<dl class="py function">255<dt class="sig sig-object py" id="select.devpoll">256<span class="sig-prename descclassname"><span class="pre">select.</span></span><span class="sig-name descname"><span class="pre">devpoll</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#select.devpoll" title="Link to this definition">¶</a></dt>257<dd><p>(Only supported on Solaris and derivatives.) Returns a <code class="docutils literal notranslate"><span class="pre">/dev/poll</span></code>258polling object; see section <a class="reference internal" href="#devpoll-objects"><span class="std std-ref">/dev/poll Polling Objects</span></a> below for the259methods supported by devpoll objects.</p>260<p><code class="xref c c-func docutils literal notranslate"><span class="pre">devpoll()</span></code> objects are linked to the number of file261descriptors allowed at the time of instantiation. If your program262reduces this value, <code class="xref c c-func docutils literal notranslate"><span class="pre">devpoll()</span></code> will fail. If your program263increases this value, <code class="xref c c-func docutils literal notranslate"><span class="pre">devpoll()</span></code> may return an264incomplete list of active file descriptors.</p>265<p>The new file descriptor is <a class="reference internal" href="os.html#fd-inheritance"><span class="std std-ref">non-inheritable</span></a>.</p>266<div class="versionadded">267<p><span class="versionmodified added">Added in version 3.3.</span></p>268</div>269<div class="versionchanged">270<p><span class="versionmodified changed">Changed in version 3.4: </span>The new file descriptor is now non-inheritable.</p>271</div>272</dd></dl>273 274<dl class="py function">275<dt class="sig sig-object py" id="select.epoll">276<span class="sig-prename descclassname"><span class="pre">select.</span></span><span class="sig-name descname"><span class="pre">epoll</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sizehint</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flags</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.epoll" title="Link to this definition">¶</a></dt>277<dd><p>(Only supported on Linux 2.5.44 and newer.) Return an edge polling object,278which can be used as Edge or Level Triggered interface for I/O279events.</p>280<p><em>sizehint</em> informs epoll about the expected number of events to be281registered. It must be positive, or <code class="docutils literal notranslate"><span class="pre">-1</span></code> to use the default. It is only282used on older systems where <code class="xref c c-func docutils literal notranslate"><span class="pre">epoll_create1()</span></code> is not available;283otherwise it has no effect (though its value is still checked).</p>284<p><em>flags</em> is deprecated and completely ignored. However, when supplied, its285value must be <code class="docutils literal notranslate"><span class="pre">0</span></code> or <code class="docutils literal notranslate"><span class="pre">select.EPOLL_CLOEXEC</span></code>, otherwise <code class="docutils literal notranslate"><span class="pre">OSError</span></code> is286raised.</p>287<p>See the <a class="reference internal" href="#epoll-objects"><span class="std std-ref">Edge and Level Trigger Polling (epoll) Objects</span></a> section below for the methods supported by288epolling objects.</p>289<p><code class="docutils literal notranslate"><span class="pre">epoll</span></code> objects support the context management protocol: when used in a290<a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> statement, the new file descriptor is automatically closed291at the end of the block.</p>292<p>The new file descriptor is <a class="reference internal" href="os.html#fd-inheritance"><span class="std std-ref">non-inheritable</span></a>.</p>293<div class="versionchanged">294<p><span class="versionmodified changed">Changed in version 3.3: </span>Added the <em>flags</em> parameter.</p>295</div>296<div class="versionchanged">297<p><span class="versionmodified changed">Changed in version 3.4: </span>Support for the <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> statement was added.298The new file descriptor is now non-inheritable.</p>299</div>300<div class="deprecated">301<p><span class="versionmodified deprecated">Deprecated since version 3.4: </span>The <em>flags</em> parameter. <code class="docutils literal notranslate"><span class="pre">select.EPOLL_CLOEXEC</span></code> is used by default now.302Use <a class="reference internal" href="os.html#os.set_inheritable" title="os.set_inheritable"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.set_inheritable()</span></code></a> to make the file descriptor inheritable.</p>303</div>304</dd></dl>305 306<dl class="py function">307<dt class="sig sig-object py" id="select.poll">308<span class="sig-prename descclassname"><span class="pre">select.</span></span><span class="sig-name descname"><span class="pre">poll</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#select.poll" title="Link to this definition">¶</a></dt>309<dd><p>(Not supported by all operating systems.) Returns a polling object, which310supports registering and unregistering file descriptors, and then polling them311for I/O events; see section <a class="reference internal" href="#poll-objects"><span class="std std-ref">Polling Objects</span></a> below for the methods supported312by polling objects.</p>313</dd></dl>314 315<dl class="py function">316<dt class="sig sig-object py" id="select.kqueue">317<span class="sig-prename descclassname"><span class="pre">select.</span></span><span class="sig-name descname"><span class="pre">kqueue</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#select.kqueue" title="Link to this definition">¶</a></dt>318<dd><p>(Only supported on BSD.) Returns a kernel queue object; see section319<a class="reference internal" href="#kqueue-objects"><span class="std std-ref">Kqueue Objects</span></a> below for the methods supported by kqueue objects.</p>320<p>The new file descriptor is <a class="reference internal" href="os.html#fd-inheritance"><span class="std std-ref">non-inheritable</span></a>.</p>321<div class="versionchanged">322<p><span class="versionmodified changed">Changed in version 3.4: </span>The new file descriptor is now non-inheritable.</p>323</div>324</dd></dl>325 326<dl class="py function">327<dt class="sig sig-object py" id="select.kevent">328<span class="sig-prename descclassname"><span class="pre">select.</span></span><span class="sig-name descname"><span class="pre">kevent</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ident</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filter</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">KQ_FILTER_READ</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flags</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">KQ_EV_ADD</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fflags</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">udata</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.kevent" title="Link to this definition">¶</a></dt>329<dd><p>(Only supported on BSD.) Returns a kernel event object; see section330<a class="reference internal" href="#kevent-objects"><span class="std std-ref">Kevent Objects</span></a> below for the methods supported by kevent objects.</p>331</dd></dl>332 333<dl class="py function">334<dt class="sig sig-object py" id="select.select">335<span class="sig-prename descclassname"><span class="pre">select.</span></span><span class="sig-name descname"><span class="pre">select</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rlist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">wlist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">xlist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.select" title="Link to this definition">¶</a></dt>336<dd><p>This is a straightforward interface to the Unix <code class="xref c c-func docutils literal notranslate"><span class="pre">select()</span></code> system call.337The first three arguments are iterables of ‘waitable objects’: either338integers representing file descriptors or objects with a parameterless method339named <a class="reference internal" href="io.html#io.IOBase.fileno" title="io.IOBase.fileno"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fileno()</span></code></a> returning such an integer:</p>340<ul class="simple">341<li><p><em>rlist</em>: wait until ready for reading</p></li>342<li><p><em>wlist</em>: wait until ready for writing</p></li>343<li><p><em>xlist</em>: wait for an “exceptional condition” (see the manual page for what344your system considers such a condition)</p></li>345</ul>346<p>Empty iterables are allowed, but acceptance of three empty iterables is347platform-dependent. (It is known to work on Unix but not on Windows.) The348optional <em>timeout</em> argument specifies a time-out in seconds; it may be349a non-integer to specify fractions of seconds.350When the <em>timeout</em> argument is omitted or <code class="docutils literal notranslate"><span class="pre">None</span></code>, the function blocks until351at least one file descriptor is ready. A time-out value of zero specifies a352poll and never blocks.</p>353<p>The return value is a triple of lists of objects that are ready: subsets of the354first three arguments. When the time-out is reached without a file descriptor355becoming ready, three empty lists are returned.</p>356<p id="index-1">Among the acceptable object types in the iterables are Python <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file357objects</span></a> (e.g. <code class="docutils literal notranslate"><span class="pre">sys.stdin</span></code>, or objects returned by358<a class="reference internal" href="functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> or <a class="reference internal" href="os.html#os.popen" title="os.popen"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.popen()</span></code></a>), socket objects returned by359<a class="reference internal" href="socket.html#socket.socket" title="socket.socket"><code class="xref py py-func docutils literal notranslate"><span class="pre">socket.socket()</span></code></a>. You may also define a <em class="dfn">wrapper</em> class yourself,360as long as it has an appropriate <a class="reference internal" href="io.html#io.IOBase.fileno" title="io.IOBase.fileno"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fileno()</span></code></a> method (that361really returns a file descriptor, not just a random integer).</p>362<div class="admonition note">363<p class="admonition-title">Note</p>364<p id="index-2">File objects on Windows are not acceptable, but sockets are. On Windows,365the underlying <code class="xref c c-func docutils literal notranslate"><span class="pre">select()</span></code> function is provided by the WinSock366library, and does not handle file descriptors that don’t originate from367WinSock.</p>368</div>369<div class="versionchanged">370<p><span class="versionmodified changed">Changed in version 3.5: </span>The function is now retried with a recomputed timeout when interrupted by371a signal, except if the signal handler raises an exception (see372<span class="target" id="index-3"></span><a class="pep reference external" href="https://peps.python.org/pep-0475/"><strong>PEP 475</strong></a> for the rationale), instead of raising373<a class="reference internal" href="exceptions.html#InterruptedError" title="InterruptedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InterruptedError</span></code></a>.</p>374</div>375<div class="versionchanged">376<p><span class="versionmodified changed">Changed in version 3.15: </span>Accepts any real number as <em>timeout</em>, not only integer or float.</p>377</div>378</dd></dl>379 380<dl class="py data">381<dt class="sig sig-object py" id="select.PIPE_BUF">382<span class="sig-prename descclassname"><span class="pre">select.</span></span><span class="sig-name descname"><span class="pre">PIPE_BUF</span></span><a class="headerlink" href="#select.PIPE_BUF" title="Link to this definition">¶</a></dt>383<dd><p>The minimum number of bytes which can be written without blocking to a pipe384when the pipe has been reported as ready for writing by <a class="reference internal" href="#select.select" title="select.select"><code class="xref py py-func docutils literal notranslate"><span class="pre">select()</span></code></a>,385<code class="xref py py-func docutils literal notranslate"><span class="pre">poll()</span></code> or another interface in this module. This doesn’t apply386to other kinds of file-like objects such as sockets.</p>387<p>This value is guaranteed by POSIX to be at least 512.</p>388<div class="availability docutils container">389<p><a class="reference internal" href="intro.html#availability"><span class="std std-ref">Availability</span></a>: Unix</p>390</div>391<div class="versionadded">392<p><span class="versionmodified added">Added in version 3.2.</span></p>393</div>394</dd></dl>395 396<section id="dev-poll-polling-objects">397<span id="devpoll-objects"></span><h2><code class="docutils literal notranslate"><span class="pre">/dev/poll</span></code> Polling Objects<a class="headerlink" href="#dev-poll-polling-objects" title="Link to this heading">¶</a></h2>398<p>Solaris and derivatives have <code class="docutils literal notranslate"><span class="pre">/dev/poll</span></code>. While <code class="xref c c-func docutils literal notranslate"><span class="pre">select()</span></code> is399<em>O</em>(<em>highest file descriptor</em>) and <code class="xref c c-func docutils literal notranslate"><span class="pre">poll()</span></code> is <em>O</em>(<em>number of file400descriptors</em>), <code class="docutils literal notranslate"><span class="pre">/dev/poll</span></code> is <em>O</em>(<em>active file descriptors</em>).</p>401<p><code class="docutils literal notranslate"><span class="pre">/dev/poll</span></code> behaviour is very close to the standard <code class="xref c c-func docutils literal notranslate"><span class="pre">poll()</span></code>402object.</p>403<dl class="py method">404<dt class="sig sig-object py" id="select.devpoll.close">405<span class="sig-prename descclassname"><span class="pre">devpoll.</span></span><span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#select.devpoll.close" title="Link to this definition">¶</a></dt>406<dd><p>Close the file descriptor of the polling object.</p>407<div class="versionadded">408<p><span class="versionmodified added">Added in version 3.4.</span></p>409</div>410</dd></dl>411 412<dl class="py attribute">413<dt class="sig sig-object py" id="select.devpoll.closed">414<span class="sig-prename descclassname"><span class="pre">devpoll.</span></span><span class="sig-name descname"><span class="pre">closed</span></span><a class="headerlink" href="#select.devpoll.closed" title="Link to this definition">¶</a></dt>415<dd><p><code class="docutils literal notranslate"><span class="pre">True</span></code> if the polling object is closed.</p>416<div class="versionadded">417<p><span class="versionmodified added">Added in version 3.4.</span></p>418</div>419</dd></dl>420 421<dl class="py method">422<dt class="sig sig-object py" id="select.devpoll.fileno">423<span class="sig-prename descclassname"><span class="pre">devpoll.</span></span><span class="sig-name descname"><span class="pre">fileno</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#select.devpoll.fileno" title="Link to this definition">¶</a></dt>424<dd><p>Return the file descriptor number of the polling object.</p>425<div class="versionadded">426<p><span class="versionmodified added">Added in version 3.4.</span></p>427</div>428</dd></dl>429 430<dl class="py method">431<dt class="sig sig-object py" id="select.devpoll.register">432<span class="sig-prename descclassname"><span class="pre">devpoll.</span></span><span class="sig-name descname"><span class="pre">register</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">eventmask</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#select.devpoll.register" title="Link to this definition">¶</a></dt>433<dd><p>Register a file descriptor with the polling object. Future calls to the434<a class="reference internal" href="#select.poll" title="select.poll"><code class="xref py py-meth docutils literal notranslate"><span class="pre">poll()</span></code></a> method will then check whether the file descriptor has any435pending I/O events. <em>fd</em> can be either an integer, or an object with a436<a class="reference internal" href="io.html#io.IOBase.fileno" title="io.IOBase.fileno"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fileno()</span></code></a> method that returns an integer. File objects437implement <code class="xref py py-meth docutils literal notranslate"><span class="pre">fileno()</span></code>, so they can also be used as the argument.</p>438<p><em>eventmask</em> is an optional bitmask describing the type of events you want to439check for. The constants are the same as with <code class="xref c c-func docutils literal notranslate"><span class="pre">poll()</span></code>440object. The default value is a combination of the constants <code class="xref py py-const docutils literal notranslate"><span class="pre">POLLIN</span></code>,441<code class="xref py py-const docutils literal notranslate"><span class="pre">POLLPRI</span></code>, and <code class="xref py py-const docutils literal notranslate"><span class="pre">POLLOUT</span></code>.</p>442<div class="admonition warning">443<p class="admonition-title">Warning</p>444<p>Registering a file descriptor that’s already registered is not an445error, but the result is undefined. The appropriate action is to446unregister or modify it first. This is an important difference447compared with <code class="xref c c-func docutils literal notranslate"><span class="pre">poll()</span></code>.</p>448</div>449</dd></dl>450 451<dl class="py method">452<dt class="sig sig-object py" id="select.devpoll.modify">453<span class="sig-prename descclassname"><span class="pre">devpoll.</span></span><span class="sig-name descname"><span class="pre">modify</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">eventmask</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#select.devpoll.modify" title="Link to this definition">¶</a></dt>454<dd><p>This method does an <a class="reference internal" href="#select.devpoll.unregister" title="select.devpoll.unregister"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unregister()</span></code></a> followed by a455<a class="reference internal" href="#select.devpoll.register" title="select.devpoll.register"><code class="xref py py-meth docutils literal notranslate"><span class="pre">register()</span></code></a>. It is (a bit) more efficient than doing the same456explicitly.</p>457</dd></dl>458 459<dl class="py method">460<dt class="sig sig-object py" id="select.devpoll.unregister">461<span class="sig-prename descclassname"><span class="pre">devpoll.</span></span><span class="sig-name descname"><span class="pre">unregister</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.devpoll.unregister" title="Link to this definition">¶</a></dt>462<dd><p>Remove a file descriptor being tracked by a polling object. Just like the463<a class="reference internal" href="#select.devpoll.register" title="select.devpoll.register"><code class="xref py py-meth docutils literal notranslate"><span class="pre">register()</span></code></a> method, <em>fd</em> can be an integer or an object with a464<a class="reference internal" href="io.html#io.IOBase.fileno" title="io.IOBase.fileno"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fileno()</span></code></a> method that returns an integer.</p>465<p>Attempting to remove a file descriptor that was never registered is466safely ignored.</p>467</dd></dl>468 469<dl class="py method">470<dt class="sig sig-object py" id="select.devpoll.poll">471<span class="sig-prename descclassname"><span class="pre">devpoll.</span></span><span class="sig-name descname"><span class="pre">poll</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">timeout</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#select.devpoll.poll" title="Link to this definition">¶</a></dt>472<dd><p>Polls the set of registered file descriptors, and returns a possibly empty list473containing <code class="docutils literal notranslate"><span class="pre">(fd,</span> <span class="pre">event)</span></code> 2-tuples for the descriptors that have events or474errors to report. <em>fd</em> is the file descriptor, and <em>event</em> is a bitmask with475bits set for the reported events for that descriptor — <code class="xref py py-const docutils literal notranslate"><span class="pre">POLLIN</span></code> for476waiting input, <code class="xref py py-const docutils literal notranslate"><span class="pre">POLLOUT</span></code> to indicate that the descriptor can be written477to, and so forth. An empty list indicates that the call timed out and no file478descriptors had any events to report. If <em>timeout</em> is given, it specifies the479length of time in milliseconds which the system will wait for events before480returning. If <em>timeout</em> is omitted, -1, or <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a>, the call will481block until there is an event for this poll object.</p>482<div class="versionchanged">483<p><span class="versionmodified changed">Changed in version 3.5: </span>The function is now retried with a recomputed timeout when interrupted by484a signal, except if the signal handler raises an exception (see485<span class="target" id="index-4"></span><a class="pep reference external" href="https://peps.python.org/pep-0475/"><strong>PEP 475</strong></a> for the rationale), instead of raising486<a class="reference internal" href="exceptions.html#InterruptedError" title="InterruptedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InterruptedError</span></code></a>.</p>487</div>488<div class="versionchanged">489<p><span class="versionmodified changed">Changed in version 3.15: </span>Accepts any real number as <em>timeout</em>, not only integer or float.</p>490</div>491</dd></dl>492 493</section>494<section id="edge-and-level-trigger-polling-epoll-objects">495<span id="epoll-objects"></span><h2>Edge and Level Trigger Polling (epoll) Objects<a class="headerlink" href="#edge-and-level-trigger-polling-epoll-objects" title="Link to this heading">¶</a></h2>496<blockquote>497<div><p><a class="reference external" href="https://linux.die.net/man/4/epoll">https://linux.die.net/man/4/epoll</a></p>498<p><em>eventmask</em></p>499<table class="docutils align-default">500<thead>501<tr class="row-odd"><th class="head"><p>Constant</p></th>502<th class="head"><p>Meaning</p></th>503</tr>504</thead>505<tbody>506<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLIN</span></code></p></td>507<td><p>Available for read</p></td>508</tr>509<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLOUT</span></code></p></td>510<td><p>Available for write</p></td>511</tr>512<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLPRI</span></code></p></td>513<td><p>Urgent data for read</p></td>514</tr>515<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLERR</span></code></p></td>516<td><p>Error condition happened on the assoc. fd</p></td>517</tr>518<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLHUP</span></code></p></td>519<td><p>Hang up happened on the assoc. fd</p></td>520</tr>521<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLET</span></code></p></td>522<td><p>Set Edge Trigger behavior, the default is523Level Trigger behavior</p></td>524</tr>525<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLONESHOT</span></code></p></td>526<td><p>Set one-shot behavior. After one event is527pulled out, the fd is internally disabled</p></td>528</tr>529<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLEXCLUSIVE</span></code></p></td>530<td><p>Wake only one epoll object when the531associated fd has an event. The default (if532this flag is not set) is to wake all epoll533objects polling on a fd.</p></td>534</tr>535<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLRDHUP</span></code></p></td>536<td><p>Stream socket peer closed connection or shut537down writing half of connection.</p></td>538</tr>539<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLRDNORM</span></code></p></td>540<td><p>Equivalent to <code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLIN</span></code></p></td>541</tr>542<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLRDBAND</span></code></p></td>543<td><p>Priority data band can be read.</p></td>544</tr>545<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLWRNORM</span></code></p></td>546<td><p>Equivalent to <code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLOUT</span></code></p></td>547</tr>548<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLWRBAND</span></code></p></td>549<td><p>Priority data may be written.</p></td>550</tr>551<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLMSG</span></code></p></td>552<td><p>Ignored.</p></td>553</tr>554<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLWAKEUP</span></code></p></td>555<td><p>Prevents sleep during event waiting.</p></td>556</tr>557</tbody>558</table>559<div class="versionadded">560<p><span class="versionmodified added">Added in version 3.6: </span><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLEXCLUSIVE</span></code> was added. It’s only supported by Linux Kernel 4.5561or later.</p>562</div>563<div class="versionadded">564<p><span class="versionmodified added">Added in version 3.14: </span><code class="xref py py-const docutils literal notranslate"><span class="pre">EPOLLWAKEUP</span></code> was added. It’s only supported by Linux Kernel 3.5565or later.</p>566</div>567</div></blockquote>568<dl class="py method">569<dt class="sig sig-object py" id="select.epoll.close">570<span class="sig-prename descclassname"><span class="pre">epoll.</span></span><span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#select.epoll.close" title="Link to this definition">¶</a></dt>571<dd><p>Close the control file descriptor of the epoll object.</p>572</dd></dl>573 574<dl class="py attribute">575<dt class="sig sig-object py" id="select.epoll.closed">576<span class="sig-prename descclassname"><span class="pre">epoll.</span></span><span class="sig-name descname"><span class="pre">closed</span></span><a class="headerlink" href="#select.epoll.closed" title="Link to this definition">¶</a></dt>577<dd><p><code class="docutils literal notranslate"><span class="pre">True</span></code> if the epoll object is closed.</p>578</dd></dl>579 580<dl class="py method">581<dt class="sig sig-object py" id="select.epoll.fileno">582<span class="sig-prename descclassname"><span class="pre">epoll.</span></span><span class="sig-name descname"><span class="pre">fileno</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#select.epoll.fileno" title="Link to this definition">¶</a></dt>583<dd><p>Return the file descriptor number of the control fd.</p>584</dd></dl>585 586<dl class="py method">587<dt class="sig sig-object py" id="select.epoll.fromfd">588<span class="sig-prename descclassname"><span class="pre">epoll.</span></span><span class="sig-name descname"><span class="pre">fromfd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.epoll.fromfd" title="Link to this definition">¶</a></dt>589<dd><p>Create an epoll object from a given file descriptor.</p>590</dd></dl>591 592<dl class="py method">593<dt class="sig sig-object py" id="select.epoll.register">594<span class="sig-prename descclassname"><span class="pre">epoll.</span></span><span class="sig-name descname"><span class="pre">register</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">eventmask</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#select.epoll.register" title="Link to this definition">¶</a></dt>595<dd><p>Register a fd descriptor with the epoll object.</p>596</dd></dl>597 598<dl class="py method">599<dt class="sig sig-object py" id="select.epoll.modify">600<span class="sig-prename descclassname"><span class="pre">epoll.</span></span><span class="sig-name descname"><span class="pre">modify</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eventmask</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.epoll.modify" title="Link to this definition">¶</a></dt>601<dd><p>Modify a registered file descriptor.</p>602</dd></dl>603 604<dl class="py method">605<dt class="sig sig-object py" id="select.epoll.unregister">606<span class="sig-prename descclassname"><span class="pre">epoll.</span></span><span class="sig-name descname"><span class="pre">unregister</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.epoll.unregister" title="Link to this definition">¶</a></dt>607<dd><p>Remove a registered file descriptor from the epoll object.</p>608<div class="versionchanged">609<p><span class="versionmodified changed">Changed in version 3.9: </span>The method no longer ignores the <a class="reference internal" href="errno.html#errno.EBADF" title="errno.EBADF"><code class="xref py py-data docutils literal notranslate"><span class="pre">EBADF</span></code></a> error.</p>610</div>611</dd></dl>612 613<dl class="py method">614<dt class="sig sig-object py" id="select.epoll.poll">615<span class="sig-prename descclassname"><span class="pre">epoll.</span></span><span class="sig-name descname"><span class="pre">poll</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">maxevents</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.epoll.poll" title="Link to this definition">¶</a></dt>616<dd><p>Wait for events.617If <em>timeout</em> is given, it specifies the length of time in seconds618(may be non-integer) which the system will wait for events before returning.</p>619<div class="versionchanged">620<p><span class="versionmodified changed">Changed in version 3.5: </span>The function is now retried with a recomputed timeout when interrupted by621a signal, except if the signal handler raises an exception (see622<span class="target" id="index-5"></span><a class="pep reference external" href="https://peps.python.org/pep-0475/"><strong>PEP 475</strong></a> for the rationale), instead of raising623<a class="reference internal" href="exceptions.html#InterruptedError" title="InterruptedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InterruptedError</span></code></a>.</p>624</div>625<div class="versionchanged">626<p><span class="versionmodified changed">Changed in version 3.15: </span>Accepts any real number as <em>timeout</em>, not only integer or float.</p>627</div>628</dd></dl>629 630</section>631<section id="polling-objects">632<span id="poll-objects"></span><h2>Polling Objects<a class="headerlink" href="#polling-objects" title="Link to this heading">¶</a></h2>633<p>The <code class="xref c c-func docutils literal notranslate"><span class="pre">poll()</span></code> system call, supported on most Unix systems, provides better634scalability for network servers that service many, many clients at the same635time. <code class="xref c c-func docutils literal notranslate"><span class="pre">poll()</span></code> scales better because the system call only requires listing636the file descriptors of interest, while <code class="xref c c-func docutils literal notranslate"><span class="pre">select()</span></code> builds a bitmap, turns637on bits for the fds of interest, and then afterward the whole bitmap has to be638linearly scanned again. <code class="xref c c-func docutils literal notranslate"><span class="pre">select()</span></code> is <em>O</em>(<em>highest file descriptor</em>), while639<code class="xref c c-func docutils literal notranslate"><span class="pre">poll()</span></code> is <em>O</em>(<em>number of file descriptors</em>).</p>640<dl class="py method">641<dt class="sig sig-object py" id="select.poll.register">642<span class="sig-prename descclassname"><span class="pre">poll.</span></span><span class="sig-name descname"><span class="pre">register</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">eventmask</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#select.poll.register" title="Link to this definition">¶</a></dt>643<dd><p>Register a file descriptor with the polling object. Future calls to the644<a class="reference internal" href="#select.poll" title="select.poll"><code class="xref py py-meth docutils literal notranslate"><span class="pre">poll()</span></code></a> method will then check whether the file descriptor has any645pending I/O events. <em>fd</em> can be either an integer, or an object with a646<a class="reference internal" href="io.html#io.IOBase.fileno" title="io.IOBase.fileno"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fileno()</span></code></a> method that returns an integer. File objects647implement <code class="xref py py-meth docutils literal notranslate"><span class="pre">fileno()</span></code>, so they can also be used as the argument.</p>648<p><em>eventmask</em> is an optional bitmask describing the type of events you want to649check for, and can be a combination of the constants <code class="xref py py-const docutils literal notranslate"><span class="pre">POLLIN</span></code>,650<code class="xref py py-const docutils literal notranslate"><span class="pre">POLLPRI</span></code>, and <code class="xref py py-const docutils literal notranslate"><span class="pre">POLLOUT</span></code>, described in the table below. If not651specified, the default value used will check for all 3 types of events.</p>652<table class="docutils align-default">653<thead>654<tr class="row-odd"><th class="head"><p>Constant</p></th>655<th class="head"><p>Meaning</p></th>656</tr>657</thead>658<tbody>659<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">POLLIN</span></code></p></td>660<td><p>There is data to read</p></td>661</tr>662<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">POLLPRI</span></code></p></td>663<td><p>There is urgent data to read</p></td>664</tr>665<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">POLLOUT</span></code></p></td>666<td><p>Ready for output: writing will not block</p></td>667</tr>668<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">POLLERR</span></code></p></td>669<td><p>Error condition of some sort</p></td>670</tr>671<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">POLLHUP</span></code></p></td>672<td><p>Hung up</p></td>673</tr>674<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">POLLRDHUP</span></code></p></td>675<td><p>Stream socket peer closed connection, or676shut down writing half of connection</p></td>677</tr>678<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">POLLNVAL</span></code></p></td>679<td><p>Invalid request: descriptor not open</p></td>680</tr>681</tbody>682</table>683<p>Registering a file descriptor that’s already registered is not an error, and has684the same effect as registering the descriptor exactly once.</p>685</dd></dl>686 687<dl class="py method">688<dt class="sig sig-object py" id="select.poll.modify">689<span class="sig-prename descclassname"><span class="pre">poll.</span></span><span class="sig-name descname"><span class="pre">modify</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eventmask</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.poll.modify" title="Link to this definition">¶</a></dt>690<dd><p>Modifies an already registered fd. This has the same effect as691<code class="docutils literal notranslate"><span class="pre">register(fd,</span> <span class="pre">eventmask)</span></code>. Attempting to modify a file descriptor692that was never registered causes an <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> exception with errno693<code class="xref py py-const docutils literal notranslate"><span class="pre">ENOENT</span></code> to be raised.</p>694</dd></dl>695 696<dl class="py method">697<dt class="sig sig-object py" id="select.poll.unregister">698<span class="sig-prename descclassname"><span class="pre">poll.</span></span><span class="sig-name descname"><span class="pre">unregister</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.poll.unregister" title="Link to this definition">¶</a></dt>699<dd><p>Remove a file descriptor being tracked by a polling object. Just like the700<a class="reference internal" href="#select.poll.register" title="select.poll.register"><code class="xref py py-meth docutils literal notranslate"><span class="pre">register()</span></code></a> method, <em>fd</em> can be an integer or an object with a701<a class="reference internal" href="io.html#io.IOBase.fileno" title="io.IOBase.fileno"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fileno()</span></code></a> method that returns an integer.</p>702<p>Attempting to remove a file descriptor that was never registered causes a703<a class="reference internal" href="exceptions.html#KeyError" title="KeyError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyError</span></code></a> exception to be raised.</p>704</dd></dl>705 706<dl class="py method">707<dt class="sig sig-object py" id="select.poll.poll">708<span class="sig-prename descclassname"><span class="pre">poll.</span></span><span class="sig-name descname"><span class="pre">poll</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">timeout</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#select.poll.poll" title="Link to this definition">¶</a></dt>709<dd><p>Polls the set of registered file descriptors, and returns a possibly empty list710containing <code class="docutils literal notranslate"><span class="pre">(fd,</span> <span class="pre">event)</span></code> 2-tuples for the descriptors that have events or711errors to report. <em>fd</em> is the file descriptor, and <em>event</em> is a bitmask with712bits set for the reported events for that descriptor — <code class="xref py py-const docutils literal notranslate"><span class="pre">POLLIN</span></code> for713waiting input, <code class="xref py py-const docutils literal notranslate"><span class="pre">POLLOUT</span></code> to indicate that the descriptor can be written714to, and so forth. An empty list indicates that the call timed out and no file715descriptors had any events to report. If <em>timeout</em> is given, it specifies the716length of time in milliseconds which the system will wait for events before717returning. If <em>timeout</em> is omitted, negative, or <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a>, the call will718block until there is an event for this poll object.</p>719<div class="versionchanged">720<p><span class="versionmodified changed">Changed in version 3.5: </span>The function is now retried with a recomputed timeout when interrupted by721a signal, except if the signal handler raises an exception (see722<span class="target" id="index-6"></span><a class="pep reference external" href="https://peps.python.org/pep-0475/"><strong>PEP 475</strong></a> for the rationale), instead of raising723<a class="reference internal" href="exceptions.html#InterruptedError" title="InterruptedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InterruptedError</span></code></a>.</p>724</div>725<div class="versionchanged">726<p><span class="versionmodified changed">Changed in version 3.15: </span>Accepts any real number as <em>timeout</em>, not only integer or float.727If <code class="docutils literal notranslate"><span class="pre">ppoll()</span></code> function is available, <em>timeout</em> has a resolution728of <code class="docutils literal notranslate"><span class="pre">1</span></code> ns (<code class="docutils literal notranslate"><span class="pre">1e-6</span></code> ms) instead of <code class="docutils literal notranslate"><span class="pre">1</span></code> ms.</p>729</div>730</dd></dl>731 732</section>733<section id="kqueue-objects">734<span id="id1"></span><h2>Kqueue Objects<a class="headerlink" href="#kqueue-objects" title="Link to this heading">¶</a></h2>735<dl class="py method">736<dt class="sig sig-object py" id="select.kqueue.close">737<span class="sig-prename descclassname"><span class="pre">kqueue.</span></span><span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#select.kqueue.close" title="Link to this definition">¶</a></dt>738<dd><p>Close the control file descriptor of the kqueue object.</p>739</dd></dl>740 741<dl class="py attribute">742<dt class="sig sig-object py" id="select.kqueue.closed">743<span class="sig-prename descclassname"><span class="pre">kqueue.</span></span><span class="sig-name descname"><span class="pre">closed</span></span><a class="headerlink" href="#select.kqueue.closed" title="Link to this definition">¶</a></dt>744<dd><p><code class="docutils literal notranslate"><span class="pre">True</span></code> if the kqueue object is closed.</p>745</dd></dl>746 747<dl class="py method">748<dt class="sig sig-object py" id="select.kqueue.fileno">749<span class="sig-prename descclassname"><span class="pre">kqueue.</span></span><span class="sig-name descname"><span class="pre">fileno</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#select.kqueue.fileno" title="Link to this definition">¶</a></dt>750<dd><p>Return the file descriptor number of the control fd.</p>751</dd></dl>752 753<dl class="py method">754<dt class="sig sig-object py" id="select.kqueue.fromfd">755<span class="sig-prename descclassname"><span class="pre">kqueue.</span></span><span class="sig-name descname"><span class="pre">fromfd</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#select.kqueue.fromfd" title="Link to this definition">¶</a></dt>756<dd><p>Create a kqueue object from a given file descriptor.</p>757</dd></dl>758 759<dl class="py method">760<dt class="sig sig-object py" id="select.kqueue.control">761<span class="sig-prename descclassname"><span class="pre">kqueue.</span></span><span class="sig-name descname"><span class="pre">control</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">changelist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_events</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">timeout</span></span></em><span class="optional">]</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">eventlist</span></span></span><a class="headerlink" href="#select.kqueue.control" title="Link to this definition">¶</a></dt>762<dd><p>Low level interface to kevent</p>763<ul class="simple">764<li><p>changelist must be an iterable of kevent objects or <code class="docutils literal notranslate"><span class="pre">None</span></code></p></li>765<li><p>max_events must be 0 or a positive integer</p></li>766<li><p>timeout in seconds (non-integers are possible); the default is <code class="docutils literal notranslate"><span class="pre">None</span></code>,767to wait forever</p></li>768</ul>769<div class="versionchanged">770<p><span class="versionmodified changed">Changed in version 3.5: </span>The function is now retried with a recomputed timeout when interrupted by771a signal, except if the signal handler raises an exception (see772<span class="target" id="index-7"></span><a class="pep reference external" href="https://peps.python.org/pep-0475/"><strong>PEP 475</strong></a> for the rationale), instead of raising773<a class="reference internal" href="exceptions.html#InterruptedError" title="InterruptedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InterruptedError</span></code></a>.</p>774</div>775<div class="versionchanged">776<p><span class="versionmodified changed">Changed in version 3.15: </span>Accepts any real number as <em>timeout</em>, not only integer or float.</p>777</div>778</dd></dl>779 780</section>781<section id="kevent-objects">782<span id="id2"></span><h2>Kevent Objects<a class="headerlink" href="#kevent-objects" title="Link to this heading">¶</a></h2>783<p><a class="reference external" href="https://man.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2">https://man.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2</a></p>784<dl class="py attribute">785<dt class="sig sig-object py" id="select.kevent.ident">786<span class="sig-prename descclassname"><span class="pre">kevent.</span></span><span class="sig-name descname"><span class="pre">ident</span></span><a class="headerlink" href="#select.kevent.ident" title="Link to this definition">¶</a></dt>787<dd><p>Value used to identify the event. The interpretation depends on the filter788but it’s usually the file descriptor. In the constructor ident can either789be an int or an object with a <a class="reference internal" href="io.html#io.IOBase.fileno" title="io.IOBase.fileno"><code class="xref py py-meth docutils literal notranslate"><span class="pre">fileno()</span></code></a> method. kevent790stores the integer internally.</p>791</dd></dl>792 793<dl class="py attribute">794<dt class="sig sig-object py" id="select.kevent.filter">795<span class="sig-prename descclassname"><span class="pre">kevent.</span></span><span class="sig-name descname"><span class="pre">filter</span></span><a class="headerlink" href="#select.kevent.filter" title="Link to this definition">¶</a></dt>796<dd><p>Name of the kernel filter.</p>797<table class="docutils align-default">798<thead>799<tr class="row-odd"><th class="head"><p>Constant</p></th>800<th class="head"><p>Meaning</p></th>801</tr>802</thead>803<tbody>804<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_READ</span></code></p></td>805<td><p>Takes a descriptor and returns whenever806there is data available to read</p></td>807</tr>808<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_WRITE</span></code></p></td>809<td><p>Takes a descriptor and returns whenever810there is data available to write</p></td>811</tr>812<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_AIO</span></code></p></td>813<td><p>AIO requests</p></td>814</tr>815<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_VNODE</span></code></p></td>816<td><p>Returns when one or more of the requested817events watched in <em>fflag</em> occurs</p></td>818</tr>819<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_PROC</span></code></p></td>820<td><p>Watch for events on a process id</p></td>821</tr>822<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_NETDEV</span></code></p></td>823<td><p>Watch for events on a network device824[not available on macOS]</p></td>825</tr>826<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_SIGNAL</span></code></p></td>827<td><p>Returns whenever the watched signal is828delivered to the process</p></td>829</tr>830<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_TIMER</span></code></p></td>831<td><p>Establishes an arbitrary timer</p></td>832</tr>833</tbody>834</table>835</dd></dl>836 837<dl class="py attribute">838<dt class="sig sig-object py" id="select.kevent.flags">839<span class="sig-prename descclassname"><span class="pre">kevent.</span></span><span class="sig-name descname"><span class="pre">flags</span></span><a class="headerlink" href="#select.kevent.flags" title="Link to this definition">¶</a></dt>840<dd><p>Filter action.</p>841<table class="docutils align-default">842<thead>843<tr class="row-odd"><th class="head"><p>Constant</p></th>844<th class="head"><p>Meaning</p></th>845</tr>846</thead>847<tbody>848<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_EV_ADD</span></code></p></td>849<td><p>Adds or modifies an event</p></td>850</tr>851<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_EV_DELETE</span></code></p></td>852<td><p>Removes an event from the queue</p></td>853</tr>854<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_EV_ENABLE</span></code></p></td>855<td><p>Permits control() to return the event</p></td>856</tr>857<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_EV_DISABLE</span></code></p></td>858<td><p>Disables event</p></td>859</tr>860<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_EV_ONESHOT</span></code></p></td>861<td><p>Removes event after first occurrence</p></td>862</tr>863<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_EV_CLEAR</span></code></p></td>864<td><p>Reset the state after an event is retrieved</p></td>865</tr>866<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_EV_SYSFLAGS</span></code></p></td>867<td><p>internal event</p></td>868</tr>869<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_EV_FLAG1</span></code></p></td>870<td><p>internal event</p></td>871</tr>872<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_EV_EOF</span></code></p></td>873<td><p>Filter specific EOF condition</p></td>874</tr>875<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_EV_ERROR</span></code></p></td>876<td><p>See return values</p></td>877</tr>878</tbody>879</table>880</dd></dl>881 882<dl class="py attribute">883<dt class="sig sig-object py" id="select.kevent.fflags">884<span class="sig-prename descclassname"><span class="pre">kevent.</span></span><span class="sig-name descname"><span class="pre">fflags</span></span><a class="headerlink" href="#select.kevent.fflags" title="Link to this definition">¶</a></dt>885<dd><p>Filter specific flags.</p>886<p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_READ</span></code> and <code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_WRITE</span></code> filter flags:</p>887<table class="docutils align-default">888<thead>889<tr class="row-odd"><th class="head"><p>Constant</p></th>890<th class="head"><p>Meaning</p></th>891</tr>892</thead>893<tbody>894<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_LOWAT</span></code></p></td>895<td><p>low water mark of a socket buffer</p></td>896</tr>897</tbody>898</table>899<p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_VNODE</span></code> filter flags:</p>900<table class="docutils align-default">901<thead>902<tr class="row-odd"><th class="head"><p>Constant</p></th>903<th class="head"><p>Meaning</p></th>904</tr>905</thead>906<tbody>907<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_DELETE</span></code></p></td>908<td><p><em>unlink()</em> was called</p></td>909</tr>910<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_WRITE</span></code></p></td>911<td><p>a write occurred</p></td>912</tr>913<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_EXTEND</span></code></p></td>914<td><p>the file was extended</p></td>915</tr>916<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_ATTRIB</span></code></p></td>917<td><p>an attribute was changed</p></td>918</tr>919<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_LINK</span></code></p></td>920<td><p>the link count has changed</p></td>921</tr>922<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_RENAME</span></code></p></td>923<td><p>the file was renamed</p></td>924</tr>925<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_REVOKE</span></code></p></td>926<td><p>access to the file was revoked</p></td>927</tr>928</tbody>929</table>930<p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_PROC</span></code> filter flags:</p>931<table class="docutils align-default">932<thead>933<tr class="row-odd"><th class="head"><p>Constant</p></th>934<th class="head"><p>Meaning</p></th>935</tr>936</thead>937<tbody>938<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_EXIT</span></code></p></td>939<td><p>the process has exited</p></td>940</tr>941<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_FORK</span></code></p></td>942<td><p>the process has called <em>fork()</em></p></td>943</tr>944<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_EXEC</span></code></p></td>945<td><p>the process has executed a new process</p></td>946</tr>947<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_PCTRLMASK</span></code></p></td>948<td><p>internal filter flag</p></td>949</tr>950<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_PDATAMASK</span></code></p></td>951<td><p>internal filter flag</p></td>952</tr>953<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_TRACK</span></code></p></td>954<td><p>follow a process across <em>fork()</em></p></td>955</tr>956<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_CHILD</span></code></p></td>957<td><p>returned on the child process for958<em>NOTE_TRACK</em></p></td>959</tr>960<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_TRACKERR</span></code></p></td>961<td><p>unable to attach to a child</p></td>962</tr>963</tbody>964</table>965<p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_FILTER_NETDEV</span></code> filter flags (not available on macOS):</p>966<table class="docutils align-default">967<thead>968<tr class="row-odd"><th class="head"><p>Constant</p></th>969<th class="head"><p>Meaning</p></th>970</tr>971</thead>972<tbody>973<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_LINKUP</span></code></p></td>974<td><p>link is up</p></td>975</tr>976<tr class="row-odd"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_LINKDOWN</span></code></p></td>977<td><p>link is down</p></td>978</tr>979<tr class="row-even"><td><p><code class="xref py py-const docutils literal notranslate"><span class="pre">KQ_NOTE_LINKINV</span></code></p></td>980<td><p>link state is invalid</p></td>981</tr>982</tbody>983</table>984</dd></dl>985 986<dl class="py attribute">987<dt class="sig sig-object py" id="select.kevent.data">988<span class="sig-prename descclassname"><span class="pre">kevent.</span></span><span class="sig-name descname"><span class="pre">data</span></span><a class="headerlink" href="#select.kevent.data" title="Link to this definition">¶</a></dt>989<dd><p>Filter specific data.</p>990</dd></dl>991 992<dl class="py attribute">993<dt class="sig sig-object py" id="select.kevent.udata">994<span class="sig-prename descclassname"><span class="pre">kevent.</span></span><span class="sig-name descname"><span class="pre">udata</span></span><a class="headerlink" href="#select.kevent.udata" title="Link to this definition">¶</a></dt>995<dd><p>User defined value.</p>996</dd></dl>997 998</section>999</section>1000 1001 1002 <div class="clearer"></div>1003 </div>1004 </div>1005 </div>1006 <div class="sphinxsidebar" role="navigation" aria-label="Main">1007 <div class="sphinxsidebarwrapper">1008 <div>1009 <h3><a href="../contents.html">Table of Contents</a></h3>1010 <ul>1011<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">select</span></code> — Waiting for I/O completion</a><ul>1012<li><a class="reference internal" href="#dev-poll-polling-objects"><code class="docutils literal notranslate"><span class="pre">/dev/poll</span></code> Polling Objects</a></li>1013<li><a class="reference internal" href="#edge-and-level-trigger-polling-epoll-objects">Edge and Level Trigger Polling (epoll) Objects</a></li>1014<li><a class="reference internal" href="#polling-objects">Polling Objects</a></li>1015<li><a class="reference internal" href="#kqueue-objects">Kqueue Objects</a></li>1016<li><a class="reference internal" href="#kevent-objects">Kevent Objects</a></li>1017</ul>1018</li>1019</ul>1020 1021 </div>1022 <div>1023 <h4>Previous topic</h4>1024 <p class="topless"><a href="ssl.html"1025 title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code> — TLS/SSL wrapper for socket objects</a></p>1026 </div>1027 <div>1028 <h4>Next topic</h4>1029 <p class="topless"><a href="selectors.html"1030 title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">selectors</span></code> — High-level I/O multiplexing</a></p>1031 </div>1032 <script>1033 document.addEventListener('DOMContentLoaded', () => {1034 const title = document.querySelector('meta[property="og:title"]').content;1035 const elements = document.querySelectorAll('.improvepage');1036 const pageurl = window.location.href.split('?')[0];1037 elements.forEach(element => {1038 const url = new URL(element.href.split('?')[0].replace("-nojs", ""));1039 url.searchParams.set('pagetitle', title);1040 url.searchParams.set('pageurl', pageurl);1041 url.searchParams.set('pagesource', "library/select.rst");1042 element.href = url.toString();1043 });1044 });1045 </script>1046 <div role="note" aria-label="source link">1047 <h3>This page</h3>1048 <ul class="this-page-menu">1049 <li><a href="../bugs.html">Report a bug</a></li>1050 <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>1051 <li>1052 <a href="https://github.com/python/cpython/blob/main/Doc/library/select.rst?plain=1"1053 rel="nofollow">Show source1054 </a>1055 </li>1056 1057 </ul>1058 </div>1059 </div>1060<div id="sidebarbutton" title="Collapse sidebar">1061<span>«</span>1062</div>1063 1064 </div>1065 <div class="clearer"></div>1066 </div> 1067 <div class="related" role="navigation" aria-label="Related">1068 <h3>Navigation</h3>1069 <ul>1070 <li class="right" style="margin-right: 10px">1071 <a href="../genindex.html" title="General Index"1072 >index</a></li>1073 <li class="right" >1074 <a href="../py-modindex.html" title="Python Module Index"1075 >modules</a> |</li>1076 <li class="right" >1077 <a href="selectors.html" title="selectors — High-level I/O multiplexing"1078 >next</a> |</li>1079 <li class="right" >1080 <a href="ssl.html" title="ssl — TLS/SSL wrapper for socket objects"1081 >previous</a> |</li>1082 1083 <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>1084 <li><a href="https://www.python.org/">Python</a> »</li>1085 <li class="switchers">1086 <div class="language_switcher_placeholder"></div>1087 <div class="version_switcher_placeholder"></div>1088 </li>1089 <li>1090 1091 </li>1092 <li id="cpython-language-and-version">1093 <a href="../index.html">3.15.0a6 Documentation</a> »1094 </li>1095 1096 <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>1097 <li class="nav-item nav-item-2"><a href="ipc.html" >Networking and Interprocess Communication</a> »</li>1098 <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">select</span></code> — Waiting for I/O completion</a></li>1099 <li class="right">1100 1101 1102 <div class="inline-search" role="search">1103 <form class="inline-search" action="../search.html" method="get">1104 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">1105 <input type="submit" value="Go">1106 </form>1107 </div>1108 |1109 </li>1110 <li class="right">1111<label class="theme-selector-label">1112 Theme1113 <select class="theme-selector" oninput="activateTheme(this.value)">1114 <option value="auto" selected>Auto</option>1115 <option value="light">Light</option>1116 <option value="dark">Dark</option>1117 </select>1118</label> |</li>1119 1120 </ul>1121 </div> 1122 <div class="footer">1123 © <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.1124 <br>1125 This page is licensed under the Python Software Foundation License Version 2.1126 <br>1127 Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.1128 <br>1129 1130 See <a href="/license.html">History and License</a> for more information.<br>1131 1132 1133 <br>1134 1135 The Python Software Foundation is a non-profit corporation.1136<a href="https://www.python.org/psf/donations/">Please donate.</a>1137<br>1138 <br>1139 Last updated on Mar 10, 2026 (08:58 UTC).1140 1141 <a href="/bugs.html">Found a bug</a>?1142 1143 <br>1144 1145 Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.1146 </div>1147 1148 </body>1149</html>