/usr/share/doc/python-tornado-doc/html/twisted.html is in python-tornado-doc 4.4.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | <!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tornado.platform.twisted — Bridges between Twisted and Tornado — Tornado 4.4.3 documentation</title>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Tornado 4.4.3 documentation" href="index.html"/>
<link rel="up" title="Integration with other services" href="integration.html"/>
<link rel="next" title="Utilities" href="utilities.html"/>
<link rel="prev" title="tornado.platform.caresresolver — Asynchronous DNS Resolver using C-Ares" href="caresresolver.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> Tornado
</a>
<div class="version">
4.4.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="guide.html">User’s guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="webframework.html">Web framework</a></li>
<li class="toctree-l1"><a class="reference internal" href="http.html">HTTP servers and clients</a></li>
<li class="toctree-l1"><a class="reference internal" href="networking.html">Asynchronous networking</a></li>
<li class="toctree-l1"><a class="reference internal" href="coroutine.html">Coroutines and concurrency</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="integration.html">Integration with other services</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="auth.html"><code class="docutils literal"><span class="pre">tornado.auth</span></code> — Third-party login with OpenID and OAuth</a></li>
<li class="toctree-l2"><a class="reference internal" href="wsgi.html"><code class="docutils literal"><span class="pre">tornado.wsgi</span></code> — Interoperability with other Python frameworks and servers</a></li>
<li class="toctree-l2"><a class="reference internal" href="asyncio.html"><code class="docutils literal"><span class="pre">tornado.platform.asyncio</span></code> — Bridge between <code class="docutils literal"><span class="pre">asyncio</span></code> and Tornado</a></li>
<li class="toctree-l2"><a class="reference internal" href="caresresolver.html"><code class="docutils literal"><span class="pre">tornado.platform.caresresolver</span></code> — Asynchronous DNS Resolver using C-Ares</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#"><code class="docutils literal"><span class="pre">tornado.platform.twisted</span></code> — Bridges between Twisted and Tornado</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="utilities.html">Utilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="releases.html">Release notes</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Tornado</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li><a href="integration.html">Integration with other services</a> »</li>
<li><code class="docutils literal"><span class="pre">tornado.platform.twisted</span></code> — Bridges between Twisted and Tornado</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/twisted.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="module-tornado.platform.twisted">
<span id="tornado-platform-twisted-bridges-between-twisted-and-tornado"></span><h1><code class="docutils literal"><span class="pre">tornado.platform.twisted</span></code> — Bridges between Twisted and Tornado<a class="headerlink" href="#module-tornado.platform.twisted" title="Permalink to this headline">¶</a></h1>
<p>Bridges between the Twisted reactor and Tornado IOLoop.</p>
<p>This module lets you run applications and libraries written for
Twisted in a Tornado application. It can be used in two modes,
depending on which library’s underlying event loop you want to use.</p>
<p>This module has been tested with Twisted versions 11.0.0 and newer.</p>
<div class="section" id="twisted-on-tornado">
<h2>Twisted on Tornado<a class="headerlink" href="#twisted-on-tornado" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="tornado.platform.twisted.TornadoReactor">
<em class="property">class </em><code class="descclassname">tornado.platform.twisted.</code><code class="descname">TornadoReactor</code><span class="sig-paren">(</span><em>io_loop=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tornado/platform/twisted.html#TornadoReactor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tornado.platform.twisted.TornadoReactor" title="Permalink to this definition">¶</a></dt>
<dd><p>Twisted reactor built on the Tornado IOLoop.</p>
<p><a class="reference internal" href="#tornado.platform.twisted.TornadoReactor" title="tornado.platform.twisted.TornadoReactor"><code class="xref py py-obj docutils literal"><span class="pre">TornadoReactor</span></code></a> implements the Twisted reactor interface on top of
the Tornado IOLoop. To use it, simply call <a class="reference internal" href="#tornado.platform.twisted.install" title="tornado.platform.twisted.install"><code class="xref py py-obj docutils literal"><span class="pre">install</span></code></a> at the beginning
of the application:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">tornado.platform.twisted</span>
<span class="n">tornado</span><span class="o">.</span><span class="n">platform</span><span class="o">.</span><span class="n">twisted</span><span class="o">.</span><span class="n">install</span><span class="p">()</span>
<span class="kn">from</span> <span class="nn">twisted.internet</span> <span class="k">import</span> <span class="n">reactor</span>
</pre></div>
</div>
<p>When the app is ready to start, call <code class="docutils literal"><span class="pre">IOLoop.current().start()</span></code>
instead of <code class="docutils literal"><span class="pre">reactor.run()</span></code>.</p>
<p>It is also possible to create a non-global reactor by calling
<code class="docutils literal"><span class="pre">tornado.platform.twisted.TornadoReactor(io_loop)</span></code>. However, if
the <a class="reference internal" href="ioloop.html#tornado.ioloop.IOLoop" title="tornado.ioloop.IOLoop"><code class="xref py py-obj docutils literal"><span class="pre">IOLoop</span></code></a> and reactor are to be short-lived (such as those used in
unit tests), additional cleanup may be required. Specifically, it is
recommended to call:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">reactor</span><span class="o">.</span><span class="n">fireSystemEvent</span><span class="p">(</span><span class="s1">'shutdown'</span><span class="p">)</span>
<span class="n">reactor</span><span class="o">.</span><span class="n">disconnectAll</span><span class="p">()</span>
</pre></div>
</div>
<p>before closing the <a class="reference internal" href="ioloop.html#tornado.ioloop.IOLoop" title="tornado.ioloop.IOLoop"><code class="xref py py-obj docutils literal"><span class="pre">IOLoop</span></code></a>.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 4.1: </span>The <code class="docutils literal"><span class="pre">io_loop</span></code> argument is deprecated.</p>
</div>
</dd></dl>
<dl class="function">
<dt id="tornado.platform.twisted.install">
<code class="descclassname">tornado.platform.twisted.</code><code class="descname">install</code><span class="sig-paren">(</span><em>io_loop=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tornado/platform/twisted.html#install"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tornado.platform.twisted.install" title="Permalink to this definition">¶</a></dt>
<dd><p>Install this package as the default Twisted reactor.</p>
<p><code class="docutils literal"><span class="pre">install()</span></code> must be called very early in the startup process,
before most other twisted-related imports. Conversely, because it
initializes the <a class="reference internal" href="ioloop.html#tornado.ioloop.IOLoop" title="tornado.ioloop.IOLoop"><code class="xref py py-obj docutils literal"><span class="pre">IOLoop</span></code></a>, it cannot be called before
<a class="reference internal" href="process.html#tornado.process.fork_processes" title="tornado.process.fork_processes"><code class="xref py py-obj docutils literal"><span class="pre">fork_processes</span></code></a> or multi-process <a class="reference internal" href="tcpserver.html#tornado.tcpserver.TCPServer.start" title="tornado.tcpserver.TCPServer.start"><code class="xref py py-obj docutils literal"><span class="pre">start</span></code></a>. These
conflicting requirements make it difficult to use <a class="reference internal" href="#tornado.platform.twisted.TornadoReactor" title="tornado.platform.twisted.TornadoReactor"><code class="xref py py-obj docutils literal"><span class="pre">TornadoReactor</span></code></a>
in multi-process mode, and an external process manager such as
<code class="docutils literal"><span class="pre">supervisord</span></code> is recommended instead.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 4.1: </span>The <code class="docutils literal"><span class="pre">io_loop</span></code> argument is deprecated.</p>
</div>
</dd></dl>
</div>
<div class="section" id="tornado-on-twisted">
<h2>Tornado on Twisted<a class="headerlink" href="#tornado-on-twisted" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="tornado.platform.twisted.TwistedIOLoop">
<em class="property">class </em><code class="descclassname">tornado.platform.twisted.</code><code class="descname">TwistedIOLoop</code><a class="reference internal" href="_modules/tornado/platform/twisted.html#TwistedIOLoop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tornado.platform.twisted.TwistedIOLoop" title="Permalink to this definition">¶</a></dt>
<dd><p>IOLoop implementation that runs on Twisted.</p>
<p><a class="reference internal" href="#tornado.platform.twisted.TwistedIOLoop" title="tornado.platform.twisted.TwistedIOLoop"><code class="xref py py-obj docutils literal"><span class="pre">TwistedIOLoop</span></code></a> implements the Tornado IOLoop interface on top of
the Twisted reactor. Recommended usage:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">tornado.platform.twisted</span> <span class="k">import</span> <span class="n">TwistedIOLoop</span>
<span class="kn">from</span> <span class="nn">twisted.internet</span> <span class="k">import</span> <span class="n">reactor</span>
<span class="n">TwistedIOLoop</span><span class="p">()</span><span class="o">.</span><span class="n">install</span><span class="p">()</span>
<span class="c1"># Set up your tornado application as usual using `IOLoop.instance`</span>
<span class="n">reactor</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
</pre></div>
</div>
<p>Uses the global Twisted reactor by default. To create multiple
<code class="docutils literal"><span class="pre">TwistedIOLoops</span></code> in the same process, you must pass a unique reactor
when constructing each one.</p>
<p>Not compatible with <a class="reference internal" href="process.html#tornado.process.Subprocess.set_exit_callback" title="tornado.process.Subprocess.set_exit_callback"><code class="xref py py-obj docutils literal"><span class="pre">tornado.process.Subprocess.set_exit_callback</span></code></a>
because the <code class="docutils literal"><span class="pre">SIGCHLD</span></code> handlers used by Tornado and Twisted conflict
with each other.</p>
<p>See also <a class="reference internal" href="ioloop.html#tornado.ioloop.IOLoop.install" title="tornado.ioloop.IOLoop.install"><code class="xref py py-meth docutils literal"><span class="pre">tornado.ioloop.IOLoop.install()</span></code></a> for general notes on
installing alternative IOLoops.</p>
</dd></dl>
</div>
<div class="section" id="twisted-dns-resolver">
<h2>Twisted DNS resolver<a class="headerlink" href="#twisted-dns-resolver" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="tornado.platform.twisted.TwistedResolver">
<em class="property">class </em><code class="descclassname">tornado.platform.twisted.</code><code class="descname">TwistedResolver</code><a class="reference internal" href="_modules/tornado/platform/twisted.html#TwistedResolver"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#tornado.platform.twisted.TwistedResolver" title="Permalink to this definition">¶</a></dt>
<dd><p>Twisted-based asynchronous resolver.</p>
<p>This is a non-blocking and non-threaded resolver. It is
recommended only when threads cannot be used, since it has
limitations compared to the standard <code class="docutils literal"><span class="pre">getaddrinfo</span></code>-based
<a class="reference internal" href="netutil.html#tornado.netutil.Resolver" title="tornado.netutil.Resolver"><code class="xref py py-obj docutils literal"><span class="pre">Resolver</span></code></a> and
<a class="reference internal" href="netutil.html#tornado.netutil.ThreadedResolver" title="tornado.netutil.ThreadedResolver"><code class="xref py py-obj docutils literal"><span class="pre">ThreadedResolver</span></code></a>. Specifically, it returns at
most one result, and arguments other than <code class="docutils literal"><span class="pre">host</span></code> and <code class="docutils literal"><span class="pre">family</span></code>
are ignored. It may fail to resolve when <code class="docutils literal"><span class="pre">family</span></code> is not
<code class="docutils literal"><span class="pre">socket.AF_UNSPEC</span></code>.</p>
<p>Requires Twisted 12.1 or newer.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 4.1: </span>The <code class="docutils literal"><span class="pre">io_loop</span></code> argument is deprecated.</p>
</div>
</dd></dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="utilities.html" class="btn btn-neutral float-right" title="Utilities" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="caresresolver.html" class="btn btn-neutral" title="tornado.platform.caresresolver — Asynchronous DNS Resolver using C-Ares" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2009-2017, The Tornado Authors.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'4.4.3',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
|