~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/howto/reactor-basics.html

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html  PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'  'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml">
 
2
  <head>
 
3
<title>Twisted Documentation: Reactor Overview</title>
 
4
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
 
5
  </head>
 
6
 
 
7
  <body bgcolor="white">
 
8
    <h1 class="title">Reactor Overview</h1>
 
9
    <div class="toc"><ol><li><a href="#auto0">Reactor Basics</a></li><li><a href="#auto1">Using the reactor object</a></li></ol></div>
 
10
    <div class="content">
 
11
 
 
12
    <span/>
 
13
 
 
14
    <p>
 
15
    This HOWTO introduces the Twisted reactor, describes the basics of the
 
16
    reactor and links to the various reactor interfaces.
 
17
    </p>
 
18
  
 
19
    <h2>Reactor Basics<a name="auto0"/></h2>
 
20
 
 
21
    <p>The reactor is the core of the event loop within Twisted -- the loop
 
22
    which drives applications using Twisted. The event loop is a programming
 
23
    construct that waits for and dispatches events or messages in a program.
 
24
    It works by calling some internal or external &quot;event provider&quot;, which
 
25
    generally blocks until an event has arrived, and then calls the relevant
 
26
    event handler (&quot;dispatches the event&quot;). The reactor provides basic
 
27
    interfaces to a number of services, including network communications,
 
28
    threading, and event dispatching.
 
29
    </p>
 
30
 
 
31
    <p>
 
32
    For information about using the reactor and the Twisted event loop, see:
 
33
    </p>
 
34
 
 
35
    <ul>
 
36
    <li>the event dispatching howtos: <a href="time.html" shape="rect">Scheduling</a> and <a href="defer.html" shape="rect">Using Deferreds</a>;</li>
 
37
    <li>the communication howtos: <a href="servers.html" shape="rect">TCP
 
38
    servers</a>, <a href="clients.html" shape="rect">TCP clients</a>, <a href="udp.html" shape="rect">UDP networking</a> and <a href="process.html" shape="rect">Using
 
39
    processes</a>; and</li>
 
40
    <li><a href="threading.html" shape="rect">Using threads</a>.</li>
 
41
    </ul>
 
42
 
 
43
    <p>There are multiple implementations of the reactor, each
 
44
    modified to provide better support for specialized features
 
45
    over the default implementation.  More information about these
 
46
    and how to use a particular implementation is available via
 
47
    <a href="choosing-reactor.html" shape="rect">Choosing a Reactor</a>.</p>
 
48
 
 
49
    
 
50
    <p>
 
51
    Twisted applications can use the interfaces in <code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.application.service.html" title="twisted.application.service">twisted.application.service</a></code> to configure and run the
 
52
    application instead of using
 
53
    boilerplate reactor code. See <a href="application.html" shape="rect">Using Application</a> for an introduction to
 
54
    Application.
 
55
    </p>
 
56
 
 
57
    <h2>Using the reactor object<a name="auto1"/></h2>
 
58
 
 
59
    <p>You can get to the <code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.internet.reactor.html" title="twisted.internet.reactor">reactor</a></code> object using the following code:</p>
 
60
 
 
61
<pre class="python"><p class="py-linenumber">1
 
62
</p><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>
 
63
</pre>
 
64
 
 
65
    <p>The reactor usually implements a set of interfaces, but 
 
66
       depending on the chosen reactor and the platform, some of
 
67
       the interfaces may not be implemented:</p>
 
68
 
 
69
    <ul>
 
70
      <li><code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.internet.interfaces.IReactorCore.html" title="twisted.internet.interfaces.IReactorCore">IReactorCore</a></code>: Core (required) functionality.</li>
 
71
      <li><code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.internet.interfaces.IReactorFDSet.html" title="twisted.internet.interfaces.IReactorFDSet">IReactorFDSet</a></code>: Use FileDescriptor objects.</li>
 
72
      <li><code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.internet.interfaces.IReactorProcess.html" title="twisted.internet.interfaces.IReactorProcess">IReactorProcess</a></code>: Process management. Read the 
 
73
        <a href="process.html" shape="rect">Using Processes</a> document for
 
74
        more information.</li>
 
75
      <li><code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.internet.interfaces.IReactorSSL.html" title="twisted.internet.interfaces.IReactorSSL">IReactorSSL</a></code>: SSL networking support.</li>
 
76
      <li><code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.internet.interfaces.IReactorTCP.html" title="twisted.internet.interfaces.IReactorTCP">IReactorTCP</a></code>: TCP networking support. More information
 
77
        can be found in the <a href="servers.html" shape="rect">Writing Servers</a>
 
78
        and <a href="clients.html" shape="rect">Writing Clients</a> documents.</li>
 
79
      <li><code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.internet.interfaces.IReactorThreads.html" title="twisted.internet.interfaces.IReactorThreads">IReactorThreads</a></code>: Threading use and management. More
 
80
        information can be found within <a href="threading.html" shape="rect">Threading In Twisted</a>.</li>
 
81
      <li><code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.internet.interfaces.IReactorTime.html" title="twisted.internet.interfaces.IReactorTime">IReactorTime</a></code>: Scheduling interface.  More information
 
82
        can be found within <a href="time.html" shape="rect">Scheduling Tasks</a>.</li>
 
83
      <li><code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.internet.interfaces.IReactorUDP.html" title="twisted.internet.interfaces.IReactorUDP">IReactorUDP</a></code>: UDP networking support. More information
 
84
        can be found within <a href="udp.html" shape="rect">UDP Networking</a>.</li>
 
85
      <li><code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.internet.interfaces.IReactorUNIX.html" title="twisted.internet.interfaces.IReactorUNIX">IReactorUNIX</a></code>: UNIX socket support.</li>
 
86
    </ul>
 
87
  </div>
 
88
 
 
89
    <p><a href="index.html">Index</a></p>
 
90
    <span class="version">Version: 10.0.0</span>
 
91
  </body>
 
92
</html>
 
 
b'\\ No newline at end of file'