<?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><title>Twisted Documentation: Reactor Overview</title><link href="../howto/stylesheet.css" type="text/css" rel="stylesheet" /></head><body bgcolor="white"><h1 class="title">Reactor Overview</h1><div class="toc"><ol><li><a href="#auto0">Reactor Basics</a></li><li><a href="#auto1">Using the reactor object</a></li></ol></div><div class="content"><span></span><p> This HOWTO introduces the Twisted reactor, describes the basics of the reactor and links to </p><h2>Reactor Basics<a name="auto0"></a></h2><p> The reactor is the core of the event loop within Twisted -- the loop which drives applications using Twisted. The reactor provides basic interfaces to a number of services, including network communications, threading, and event dispatching. </p><p> For information about using the reactor and the Twisted event loop, see: </p><ul><li>the event dispatching howtos: <a href="time.html">Scheduling</a> and <a href="defer.html">Using Deferreds</a>;</li><li>the communication howtos: <a href="servers.html">TCP servers</a>, <a href="clients.html">TCP clients</a>, <a href="udp.html">UDP networking</a> and <a href="process.html">Using processes</a>; and</li><li><a href="threading.html">Using threads</a>.</li></ul><p> There are multiple implementations of the reactor, each modified to provide better support for specialized features over the default implementation. More information about these and how to use a particular implementation is available via <a href="choosing-reactor.html">Choosing a Reactor</a>. </p><p> Twisted applications can use the interfaces in <code class="API">twisted.application.service</code> to configure and run the application instead of using boilerplate reactor code. See <a href="application.html">Using Application</a> for an introduction to Application. </p><h2>Using the reactor object<a name="auto1"></a></h2><p> You can get to the <code base="twisted.internet" class="API">reactor</code> object using the following code:</p><pre class="python"> <span class="py-src-keyword">from</span> <span class="py-src-variable">twisted</span>.<span class="py-src-variable">internet</span> <span class="py-src-keyword">import</span> <span class="py-src-variable">reactor</span> </pre><p> The reactor usually implements a set of interfaces, but depending on the chosen reactor and the platform, some of the interfaces may not be implemented: </p><ul><li><code base="twisted.internet.interfaces" class="API">IReactorCore</code>: Core (required) functionality.</li><li><code base="twisted.internet.interfaces" class="API">IReactorFDSet</code>: Use FileDescriptor objects.</li><li><code base="twisted.internet.interfaces" class="API">IReactorProcess</code>: Process management. Read the <a href="process.html">Using Processes</a> document for more information.</li><li><code base="twisted.internet.interfaces" class="API">IReactorSSL</code>: SSL networking support.</li><li><code base="twisted.internet.interfaces" class="API">IReactorTCP</code>: TCP networking support. More information can be found in the <a href="servers.html">Writing Servers</a> and <a href="clients.html">Writing Clients</a> documents.</li><li><code base="twisted.internet.interfaces" class="API">IReactorThreads</code>: Threading use and management. More information can be found within <a href="threading.html">Threading In Twisted</a>.</li><li><code base="twisted.internet.interfaces" class="API">IReactorTime</code>: Scheduling interface. More information can be found within <a href="time.html">Scheduling Tasks</a>.</li><li><code base="twisted.internet.interfaces" class="API">IReactorUDP</code>: UDP networking support. More information can be found within <a href="udp.html">UDP Networking</a>.</li><li><code base="twisted.internet.interfaces" class="API">IReactorUNIX</code>: UNIX socket support.</li></ul></div><p><a href="../howto/index.html">Index</a></p><span class="version">Version: 2.5.0</span></body></html>