Ticket #1272: interfaces_1272.diff

File interfaces_1272.diff, 36.9 KB (added by therve, 3 years ago)
  • twisted/internet/interfaces.py

     
    22# See LICENSE for details. 
    33 
    44 
    5 """Interface documentation. 
     5""" 
     6Interface documentation. 
    67 
    78API Stability: stable, other than IReactorUDP (semi-stable) and 
    89IReactorMulticast (unstable). 
     
    1415 
    1516 
    1617class IAddress(Interface): 
    17     """An address, e.g. a TCP (host, port). 
     18    """ 
     19    An address, e.g. a TCP (host, port). 
    1820 
    1921    Default implementations are in L{twisted.internet.address}. 
    2022    """ 
     
    2325### Reactor Interfaces 
    2426 
    2527class IConnector(Interface): 
    26     """Object used to interface between connections and protocols. 
     28    """ 
     29    Object used to interface between connections and protocols. 
    2730 
    2831    Each IConnector manages one connection. 
    2932    """ 
    3033 
    3134    def stopConnecting(): 
    32         """Stop attempting to connect.""" 
     35        """ 
     36        Stop attempting to connect. 
     37        """ 
    3338 
    3439    def disconnect(): 
    35         """Disconnect regardless of the connection state. 
     40        """ 
     41        Disconnect regardless of the connection state. 
    3642 
    3743        If we are connected, disconnect, if we are trying to connect, 
    3844        stop trying. 
    3945        """ 
    4046 
    4147    def connect(): 
    42         """Try to connect to remote address.""" 
     48        """ 
     49        Try to connect to remote address. 
     50        """ 
    4351 
    4452    def getDestination(): 
    45         """Return destination this will try to connect to. 
     53        """ 
     54        Return destination this will try to connect to. 
    4655 
    4756        @return: An object which provides L{IAddress}. 
    4857        """ 
    4958 
    5059 
    5160class IResolverSimple(Interface): 
     61 
    5262    def getHostByName(name, timeout = (1, 3, 11, 45)): 
    53         """Resolve the domain name C{name} into an IP address. 
     63        """ 
     64        Resolve the domain name C{name} into an IP address. 
    5465 
    5566        @type name: C{str} 
    5667        @type timeout: C{tuple} 
     
    6879        """ 
    6980 
    7081class IResolver(IResolverSimple): 
     82 
    7183    def lookupRecord(name, cls, type, timeout = 10): 
    72         """Lookup the records associated with the given name 
    73            that are of the given type and in the given class. 
    7484        """ 
     85        Lookup the records associated with the given name 
     86        that are of the given type and in the given class. 
     87        """ 
    7588 
    7689    def query(query, timeout = 10): 
    77         """Interpret and dispatch a query object to the appropriate 
     90        """ 
     91        Interpret and dispatch a query object to the appropriate 
    7892        lookup* method. 
    7993        """ 
    8094 
    8195    def lookupAddress(name, timeout = 10): 
    82         """Lookup the A records associated with C{name}.""" 
     96        """ 
     97        Lookup the A records associated with C{name}. 
     98        """ 
    8399 
    84100    def lookupAddress6(name, timeout = 10): 
    85         """Lookup all the A6 records associated with C{name}.""" 
     101        """ 
     102        Lookup all the A6 records associated with C{name}. 
     103        """ 
    86104 
    87105    def lookupIPV6Address(name, timeout = 10): 
    88         """Lookup all the AAAA records associated with C{name}.""" 
     106        """ 
     107        Lookup all the AAAA records associated with C{name}. 
     108        """ 
    89109 
    90110    def lookupMailExchange(name, timeout = 10): 
    91         """Lookup the MX records associated with C{name}.""" 
     111        """ 
     112        Lookup the MX records associated with C{name}. 
     113        """ 
    92114 
    93115    def lookupNameservers(name, timeout = 10): 
    94         """Lookup the the NS records associated with C{name}.""" 
     116        """ 
     117        Lookup the the NS records associated with C{name}. 
     118        """ 
    95119 
    96120    def lookupCanonicalName(name, timeout = 10): 
    97         """Lookup the CNAME records associated with C{name}.""" 
     121        """ 
     122        Lookup the CNAME records associated with C{name}. 
     123        """ 
    98124 
    99125    def lookupMailBox(name, timeout = 10): 
    100         """Lookup the MB records associated with C{name}.""" 
     126        """ 
     127        Lookup the MB records associated with C{name}. 
     128        """ 
    101129 
    102130    def lookupMailGroup(name, timeout = 10): 
    103         """Lookup the MG records associated with C{name}.""" 
     131        """ 
     132        Lookup the MG records associated with C{name}. 
     133        """ 
    104134 
    105135    def lookupMailRename(name, timeout = 10): 
    106         """Lookup the MR records associated with C{name}.""" 
     136        """ 
     137        Lookup the MR records associated with C{name}. 
     138        """ 
    107139 
    108140    def lookupPointer(name, timeout = 10): 
    109         """Lookup the PTR records associated with C{name}.""" 
     141        """ 
     142        Lookup the PTR records associated with C{name}. 
     143        """ 
    110144 
    111145    def lookupAuthority(name, timeout = 10): 
    112         """Lookup the SOA records associated with C{name}.""" 
     146        """ 
     147        Lookup the SOA records associated with C{name}. 
     148        """ 
    113149 
    114150    def lookupNull(name, timeout = 10): 
    115         """Lookup the NULL records associated with C{name}.""" 
     151        """ 
     152        Lookup the NULL records associated with C{name}. 
     153        """ 
    116154 
    117155    def lookupWellKnownServices(name, timeout = 10): 
    118         """Lookup the WKS records associated with C{name}.""" 
     156        """ 
     157        Lookup the WKS records associated with C{name}. 
     158        """ 
    119159 
    120160    def lookupHostInfo(name, timeout = 10): 
    121         """Lookup the HINFO records associated with C{name}.""" 
     161        """ 
     162        Lookup the HINFO records associated with C{name}. 
     163        """ 
    122164 
    123165    def lookupMailboxInfo(name, timeout = 10): 
    124         """Lookup the MINFO records associated with C{name}.""" 
     166        """ 
     167        Lookup the MINFO records associated with C{name}. 
     168        """ 
    125169 
    126170    def lookupText(name, timeout = 10): 
    127         """Lookup the TXT records associated with C{name}.""" 
     171        """ 
     172        Lookup the TXT records associated with C{name}. 
     173        """ 
    128174 
    129175    def lookupResponsibility(name, timeout = 10): 
    130         """Lookup the RP records associated with C{name}.""" 
     176        """ 
     177        Lookup the RP records associated with C{name}. 
     178        """ 
    131179 
    132180    def lookupAFSDatabase(name, timeout = 10): 
    133         """Lookup the AFSDB records associated with C{name}.""" 
     181        """ 
     182        Lookup the AFSDB records associated with C{name}. 
     183        """ 
    134184 
    135185    def lookupService(name, timeout = 10): 
    136         """Lookup the SRV records associated with C{name}.""" 
     186        """ 
     187        Lookup the SRV records associated with C{name}. 
     188        """ 
    137189 
    138190    def lookupAllRecords(name, timeout = 10): 
    139         """Lookup all records associated with C{name}.""" 
     191        """ 
     192        Lookup all records associated with C{name}. 
     193        """ 
    140194 
    141195    def lookupZone(name, timeout = 10): 
    142         """Perform a zone transfer for the given C{name}.""" 
     196        """ 
     197        Perform a zone transfer for the given C{name}. 
     198        """ 
    143199 
    144200 
    145201class IReactorArbitrary(Interface): 
     202 
    146203    def listenWith(portType, *args, **kw): 
    147         """Start an instance of the given C{portType} listening. 
     204        """ 
     205        Start an instance of the given C{portType} listening. 
    148206 
    149207        @type portType: type which implements L{IListeningPort} 
    150208 
     
    169227class IReactorTCP(Interface): 
    170228 
    171229    def listenTCP(port, factory, backlog=50, interface=''): 
    172         """Connects a given protocol factory to the given numeric TCP/IP port. 
     230        """ 
     231        Connects a given protocol factory to the given numeric TCP/IP port. 
    173232 
    174233        @param port: a port number on which to listen 
    175234 
     
    188247        """ 
    189248 
    190249    def connectTCP(host, port, factory, timeout=30, bindAddress=None): 
    191         """Connect a TCP client. 
     250        """ 
     251        Connect a TCP client. 
    192252 
    193253        @param host: a host name 
    194254 
     
    212272class IReactorSSL(Interface): 
    213273 
    214274    def connectSSL(host, port, factory, contextFactory, timeout=30, bindAddress=None): 
    215         """Connect a client Protocol to a remote SSL socket. 
     275        """ 
     276        Connect a client Protocol to a remote SSL socket. 
    216277 
    217278        @param host: a host name 
    218279 
     
    250311 
    251312 
    252313class IReactorUNIX(Interface): 
    253     """UNIX socket methods.""" 
     314    """ 
     315    UNIX socket methods. 
     316    """ 
    254317 
    255318    def connectUNIX(address, factory, timeout=30, checkPID=0): 
    256         """Connect a client protocol to a UNIX socket. 
     319        """ 
     320        Connect a client protocol to a UNIX socket. 
    257321 
    258322        @param address: a path to a unix socket on the filesystem. 
    259323 
     
    269333        """ 
    270334 
    271335    def listenUNIX(address, factory, backlog=50, mode=0666, wantPID=0): 
    272         """Listen on a UNIX socket. 
     336        """ 
     337        Listen on a UNIX socket. 
    273338 
    274339        @param address: a path to a unix socket on the filesystem. 
    275340 
     
    286351 
    287352 
    288353class IReactorUNIXDatagram(Interface): 
    289     """datagram UNIX socket methods.""" 
     354    """ 
     355    Datagram UNIX socket methods. 
     356    """ 
    290357 
    291358    def connectUNIXDatagram(address, protocol, maxPacketSize=8192, mode=0666, bindAddress=None): 
    292         """Connect a client protocol to a datagram UNIX socket. 
     359        """ 
     360        Connect a client protocol to a datagram UNIX socket. 
    293361 
    294362        @param address: a path to a unix socket on the filesystem. 
    295363 
     
    305373        """ 
    306374 
    307375    def listenUNIXDatagram(address, protocol, maxPacketSize=8192, mode=0666): 
    308         """Listen on a datagram UNIX socket. 
     376        """ 
     377        Listen on a datagram UNIX socket. 
    309378 
    310379        @param address: a path to a unix socket on the filesystem. 
    311380 
     
    320389 
    321390 
    322391class IReactorUDP(Interface): 
    323     """UDP socket methods. 
     392    """ 
     393    UDP socket methods. 
    324394 
    325395    IMPORTANT: This is an experimental new interface. It may change 
    326396    without backwards compatability. Suggestions are welcome. 
    327397    """ 
    328398 
    329399    def listenUDP(port, protocol, interface='', maxPacketSize=8192): 
    330         """Connects a given DatagramProtocol to the given numeric UDP port. 
     400        """ 
     401        Connects a given DatagramProtocol to the given numeric UDP port. 
    331402 
    332403        @return: object which provides L{IListeningPort}. 
    333404        """ 
    334405 
    335406    def connectUDP(remotehost, remoteport, protocol, localport=0, 
    336407                  interface='', maxPacketSize=8192): 
    337         """DEPRECATED. 
     408        """ 
     409        DEPRECATED. 
    338410 
    339411        Connects a L{twisted.internet.protocol.ConnectedDatagramProtocol} 
    340412        instance to a UDP port. 
     
    342414 
    343415 
    344416class IReactorMulticast(Interface): 
    345     """UDP socket methods that support multicast. 
     417    """ 
     418    UDP socket methods that support multicast. 
    346419 
    347420    IMPORTANT: This is an experimental new interface. It may change 
    348421    without backwards compatability. Suggestions are welcome. 
     
    366439 
    367440    def spawnProcess(processProtocol, executable, args=(), env={}, path=None, 
    368441                     uid=None, gid=None, usePTY=0, childFDs=None): 
    369         """Spawn a process, with a process protocol. 
     442        """ 
     443        Spawn a process, with a process protocol. 
    370444 
    371445        @param processProtocol: a L{twisted.internet.protocol.ProcessProtocol} instance 
    372446 
     
    430504        """ 
    431505 
    432506class IReactorTime(Interface): 
    433     """Time methods that a Reactor should implement. 
    434507    """ 
     508    Time methods that a Reactor should implement. 
     509    """ 
    435510 
    436511    def callLater(delay, callable, *args, **kw): 
    437         """Call a function later. 
     512        """ 
     513        Call a function later. 
    438514 
    439515        @type delay:  C{float} 
    440516        @param delay: the number of seconds to wait. 
     
    452528        """ 
    453529 
    454530    def cancelCallLater(callID): 
    455         """This method is deprecated. 
     531        """ 
     532        This method is deprecated. 
    456533 
    457534        Cancel a call that would happen later. 
    458535 
     
    463540        """ 
    464541 
    465542    def getDelayedCalls(): 
    466         """Retrieve all currently scheduled delayed calls. 
     543        """ 
     544        Retrieve all currently scheduled delayed calls. 
    467545 
    468546        @return: A tuple of all L{IDelayedCall} providers representing all 
    469547                 currently scheduled calls. This is everything that has been 
     
    472550 
    473551 
    474552class IDelayedCall(Interface): 
    475     """A scheduled call. 
     553    """ 
     554    A scheduled call. 
    476555 
    477556    There are probably other useful methods we can add to this interface; 
    478557    suggestions are welcome. 
    479558    """ 
    480559 
    481560    def getTime(): 
    482         """Get time when delayed call will happen. 
     561        """ 
     562        Get time when delayed call will happen. 
    483563 
    484564        @return: time in seconds since epoch (a float). 
    485565        """ 
    486566 
    487567    def cancel(): 
    488         """Cancel the scheduled call. 
     568        """ 
     569        Cancel the scheduled call. 
    489570 
    490571        @raises twisted.internet.error.AlreadyCalled: if the call has already 
    491572            happened. 
     
    494575        """ 
    495576 
    496577    def delay(secondsLater): 
    497         """Delay the scheduled call. 
     578        """ 
     579        Delay the scheduled call. 
    498580 
    499581        @param secondsLater: how many seconds from its current firing time to delay 
    500582 
     
    505587        """ 
    506588 
    507589    def reset(secondsFromNow): 
    508         """Reset the scheduled call's timer. 
     590        """ 
     591        Reset the scheduled call's timer. 
    509592 
    510593        @param secondsFromNow: how many seconds from now it should fire, 
    511594            equivalent to C{.cancel()} and then doing another 
     
    524607        """ 
    525608 
    526609class IReactorThreads(Interface): 
    527     """Dispatch methods to be run in threads. 
     610    """ 
     611    Dispatch methods to be run in threads. 
    528612 
    529613    Internally, this should use a thread pool and dispatch methods to them. 
    530614    """ 
    531615 
    532616    def callInThread(callable, *args, **kwargs): 
    533         """Run the callable object in a separate thread. 
    534617        """ 
     618        Run the callable object in a separate thread. 
     619        """ 
    535620 
    536621    def callFromThread(callable, *args, **kw): 
    537         """Cause a function to be executed by the reactor thread. 
     622        """ 
     623        Cause a function to be executed by the reactor thread. 
    538624 
    539625        Use this method when you want to run a function in the reactor's thread 
    540626        from another thread.  Calling callFromThread should wake up the main 
     
    554640 
    555641 
    556642class IReactorCore(Interface): 
    557     """Core methods that a Reactor must implement. 
    558643    """ 
     644    Core methods that a Reactor must implement. 
     645    """ 
    559646 
    560647    def resolve(name, timeout=10): 
    561         """Return a L{twisted.internet.defer.Deferred} that will resolve a hostname. 
    562648        """ 
     649        Return a L{twisted.internet.defer.Deferred} that will resolve a hostname. 
     650        """ 
    563651 
    564  
    565652    def run(): 
    566         """Fire 'startup' System Events, move the reactor to the 'running' 
     653        """ 
     654        Fire 'startup' System Events, move the reactor to the 'running' 
    567655        state, then run the main loop until it is stopped with stop() or 
    568656        crash(). 
    569657        """ 
    570658 
    571659    def stop(): 
    572         """Fire 'shutdown' System Events, which will move the reactor to the 
    573         'stopped' state and cause reactor.run() to exit. """ 
     660        """ 
     661        Fire 'shutdown' System Events, which will move the reactor to the 
     662        'stopped' state and cause reactor.run() to exit. 
     663        """ 
    574664 
    575665    def crash(): 
    576         """Stop the main loop *immediately*, without firing any system events. 
     666        """ 
     667        Stop the main loop *immediately*, without firing any system events. 
    577668 
    578669        This is named as it is because this is an extremely "rude" thing to do; 
    579670        it is possible to lose data and put your system in an inconsistent 
     
    582673        """ 
    583674 
    584675    def iterate(delay=0): 
    585         """Run the main loop's I/O polling function for a period of time. 
     676        """ 
     677        Run the main loop's I/O polling function for a period of time. 
    586678 
    587679        This is most useful in applications where the UI is being drawn "as 
    588680        fast as possible", such as games. All pending L{IDelayedCall}s will 
     
    596688        """ 
    597689 
    598690    def fireSystemEvent(eventType): 
    599         """Fire a system-wide event. 
     691        """ 
     692        Fire a system-wide event. 
    600693 
    601694        System-wide events are things like 'startup', 'shutdown', and 
    602695        'persist'. 
    603696        """ 
    604697 
    605698    def addSystemEventTrigger(phase, eventType, callable, *args, **kw): 
    606         """Add a function to be called when a system event occurs. 
     699        """ 
     700        Add a function to be called when a system event occurs. 
    607701 
    608702        Each "system event" in Twisted, such as 'startup', 'shutdown', and 
    609703        'persist', has 3 phases: 'before', 'during', and 'after' (in that 
     
    637731        """ 
    638732 
    639733    def removeSystemEventTrigger(triggerID): 
    640         """Removes a trigger added with addSystemEventTrigger. 
     734        """ 
     735        Removes a trigger added with addSystemEventTrigger. 
    641736 
    642737        @param triggerID: a value returned from addSystemEventTrigger. 
    643738        """ 
    644739 
    645740    def callWhenRunning(callable, *args, **kw): 
    646         """Call a function when the reactor is running. 
     741        """ 
     742        Call a function when the reactor is running. 
    647743 
    648744        If the reactor has not started, the callable will be scheduled 
    649745        to run when it does start. Otherwise, the callable will be invoked 
     
    661757 
    662758 
    663759class IReactorPluggableResolver(Interface): 
    664     """A reactor with a pluggable name resolver interface. 
    665760    """ 
     761    A reactor with a pluggable name resolver interface. 
     762    """ 
    666763    def installResolver(resolver): 
    667         """Set the internal resolver to use to for name lookups. 
     764        """ 
     765        Set the internal resolver to use to for name lookups. 
    668766 
    669767        @type resolver: An object implementing the L{IResolverSimple} interface 
    670768        @param resolver: The new resolver to use. 
     
    683781    """ 
    684782 
    685783    def addReader(reader): 
    686         """I add reader to the set of file descriptors to get read events for. 
     784        """ 
     785        I add reader to the set of file descriptors to get read events for. 
    687786 
    688787        @param reader: An L{IReadDescriptor} provider that will be checked for 
    689788                       read events until it is removed from the reactor with 
     
    693792        """ 
    694793 
    695794    def addWriter(writer): 
    696         """I add writer to the set of file descriptors to get write events for. 
     795        """ 
     796        I add writer to the set of file descriptors to get write events for. 
    697797 
    698798        @param writer: An L{IWriteDescriptor} provider that will be checked for 
    699799                       read events until it is removed from the reactor with 
     
    703803        """ 
    704804 
    705805    def removeReader(reader): 
    706         """Removes an object previously added with L{addReader}. 
     806        """ 
     807        Removes an object previously added with L{addReader}. 
    707808 
    708809        @return: C{None}. 
    709810        """ 
    710811 
    711812    def removeWriter(writer): 
    712         """Removes an object previously added with L{addWriter}. 
     813        """ 
     814        Removes an object previously added with L{addWriter}. 
    713815 
    714816        @return: C{None}. 
    715817        """ 
    716818 
    717819    def removeAll(): 
    718         """Remove all readers and writers. 
     820        """ 
     821        Remove all readers and writers. 
    719822 
    720823        Should not remove reactor internal reactor connections (like a waker). 
    721824 
     
    725828 
    726829 
    727830class IListeningPort(Interface): 
    728     """A listening port. 
    729831    """ 
     832    A listening port. 
     833    """ 
    730834 
    731835    def startListening(): 
    732         """Start listening on this port. 
     836        """ 
     837        Start listening on this port. 
    733838 
    734839        @raise CannotListenError: If it cannot listen on this port (e.g., it is 
    735840                                  a TCP port and it cannot bind to the required 
     
    737842        """ 
    738843 
    739844    def stopListening(): 
    740         """Stop listening on this port. 
     845        """ 
     846        Stop listening on this port. 
    741847 
    742848        If it does not complete immediately, will return Deferred that fires 
    743849        upon completion. 
    744850        """ 
    745851 
    746852    def getHost(): 
    747         """Get the host that this port is listening for. 
     853        """ 
     854        Get the host that this port is listening for. 
    748855 
    749856        @return: An L{IAddress} provider. 
    750857        """ 
    751858 
    752859 
    753860class IFileDescriptor(Interface): 
    754     """A file descriptor. 
    755861    """ 
     862    A file descriptor. 
     863    """ 
    756864 
    757865    def fileno(): 
    758866        """ 
     
    761869        """ 
    762870 
    763871    def connectionLost(reason): 
    764         """Called when the connection was lost. 
     872        """ 
     873        Called when the connection was lost. 
    765874 
    766875        This is called when the connection on a selectable object has been 
    767876        lost.  It will be called whether the connection was closed explicitly, 
     
    777886                       failure may be of other classes as well. 
    778887        """ 
    779888 
     889    def logPrefix(): 
     890        """ 
     891        Prefix used when logging execution of reading or writing from this 
     892        descriptor. 
     893        """ 
     894 
    780895class IReadDescriptor(IFileDescriptor): 
    781896 
    782897    def doRead(): 
    783         """Some data is available for reading on your descriptor. 
    784898        """ 
     899        Some data is available for reading on your descriptor. 
     900        """ 
    785901 
    786902 
    787903class IWriteDescriptor(IFileDescriptor): 
    788904 
    789905    def doWrite(): 
    790         """Some data can be written to your descriptor. 
    791906        """ 
     907        Some data can be written to your descriptor. 
     908        """ 
    792909 
    793910 
    794911class IReadWriteDescriptor(IReadDescriptor, IWriteDescriptor): 
    795     """I am a L{FileDescriptor<twisted.internet.abstract.FileDescriptor>} that can both read and write. 
    796912    """ 
     913    I am a L{FileDescriptor<twisted.internet.abstract.FileDescriptor>} that can both read and write. 
     914    """ 
    797915 
    798916 
    799917class IHalfCloseableDescriptor(Interface): 
    800     """A descriptor that can be half-closed.""" 
     918    """ 
     919    A descriptor that can be half-closed. 
     920    """ 
    801921 
    802922    def writeConnectionLost(reason): 
    803         """Indicates write connection was lost.""" 
     923        """ 
     924        Indicates write connection was lost. 
     925        """ 
    804926 
    805927    def readConnectionLost(reason): 
    806         """Indicates read connection was lost.""" 
     928        """ 
     929        Indicates read connection was lost. 
     930        """ 
    807931 
    808932 
    809933class ISystemHandle(Interface): 
    810     """An object that wraps a networking OS-specific handle.""" 
     934    """ 
     935    An object that wraps a networking OS-specific handle. 
     936    """ 
    811937 
    812938    def getHandle(): 
    813         """Return a system- and reactor-specific handle. 
     939        """ 
     940        Return a system- and reactor-specific handle. 
    814941 
    815942        This might be a socket.socket() object, or some other type of 
    816943        object, depending on which reactor is being used. Use and 
     
    822949 
    823950 
    824951class IConsumer(Interface): 
    825     """A consumer consumes data from a producer.""" 
     952    """ 
     953    A consumer consumes data from a producer. 
     954    """ 
    826955 
    827956    def registerProducer(producer, streaming): 
    828957        """ 
     
    850979        """ 
    851980 
    852981    def unregisterProducer(): 
    853         """Stop consuming data from a producer, without disconnecting. 
    854982        """ 
     983        Stop consuming data from a producer, without disconnecting. 
     984        """ 
    855985 
    856986    def write(data): 
    857         """The producer will write data by calling this method.""" 
     987        """ 
     988        The producer will write data by calling this method. 
     989        """ 
    858990 
    859991class IFinishableConsumer(IConsumer): 
    860     """A Consumer for producers that finish. 
     992    """ 
     993    A Consumer for producers that finish. 
    861994 
    862995    This interface is semi-stable. 
    863996    """ 
    864997    def finish(): 
    865         """The producer has finished producing.""" 
     998        """ 
     999        The producer has finished producing. 
     1000        """ 
    8661001 
    8671002class IProducer(Interface): 
    868     """A producer produces data for a consumer. 
     1003    """ 
     1004    A producer produces data for a consumer. 
    8691005 
    8701006    Typically producing is done by calling the write method of an class 
    8711007    implementing L{IConsumer}. 
    8721008    """ 
    8731009 
    8741010    def stopProducing(): 
    875         """Stop producing data. 
     1011        """ 
     1012        Stop producing data. 
    8761013 
    8771014        This tells a producer that its consumer has died, so it must stop 
    8781015        producing data for good. 
     
    8911028    """ 
    8921029 
    8931030    def pauseProducing(): 
    894         """Pause producing data. 
     1031        """ 
     1032        Pause producing data. 
    8951033 
    8961034        Tells a producer that it has produced too much data to process for 
    8971035        the time being, and to stop until resumeProducing() is called. 
    8981036        """ 
    8991037    def resumeProducing(): 
    900         """Resume producing data. 
     1038        """ 
     1039        Resume producing data. 
    9011040 
    9021041        This tells a producer to re-add itself to the main loop and produce 
    9031042        more data for its consumer. 
     
    9121051    """ 
    9131052 
    9141053    def resumeProducing(): 
    915         """Produce data for the consumer a single time. 
     1054        """ 
     1055        Produce data for the consumer a single time. 
    9161056 
    9171057        This tells a producer to produce data for the consumer once 
    9181058        (not repeatedly, once only). Typically this will be done 
     
    9231063class IProtocol(Interface): 
    9241064 
    9251065    def dataReceived(data): 
    926         """Called whenever data is received. 
     1066        """ 
     1067        Called whenever data is received. 
    9271068 
    9281069        Use this method to translate to a higher-level message.  Usually, some 
    9291070        callback will be made upon the receipt of each complete protocol 
     
    9371078        """ 
    9381079 
    9391080    def connectionLost(reason): 
    940         """Called when the connection is shut down. 
     1081        """ 
     1082        Called when the connection is shut down. 
    9411083 
    9421084        Clear any circular references here, and any external references 
    9431085        to this Protocol.  The connection has been closed. The C{reason} 
     
    9491091        """ 
    9501092 
    9511093    def makeConnection(transport): 
    952         """Make a connection to a transport and a server. 
    9531094        """ 
     1095        Make a connection to a transport and a server. 
     1096        """ 
    9541097 
    9551098    def connectionMade(): 
    956         """Called when a connection is made. 
     1099        """ 
     1100        Called when a connection is made. 
    9571101 
    9581102        This may be considered the initializer of the protocol, because 
    9591103        it is called when the connection is completed.  For clients, 
     
    9651109 
    9661110 
    9671111class IHalfCloseableProtocol(Interface): 
    968     """Implemented to indicate they want notification of half-closes. 
     1112    """ 
     1113    Implemented to indicate they want notification of half-closes. 
    9691114 
    9701115    TCP supports the notion of half-closing the connection, e.g. 
    9711116    closing the write side but still not stopping reading. A protocol 
     
    9741119    """ 
    9751120 
    9761121    def readConnectionLost(): 
    977         """Notification of the read connection being closed. 
     1122        """ 
     1123        Notification of the read connection being closed. 
    9781124 
    9791125        This indicates peer did half-close of write side. It is now 
    9801126        the responsiblity of the this protocol to call 
     
    9881134        """ 
    9891135 
    9901136    def writeConnectionLost(): 
    991         """Notification of the write connection being closed. 
     1137        """ 
     1138        Notification of the write connection being closed. 
    9921139 
    9931140        This will never be called for TCP connections as TCP does not 
    9941141        support notification of this type of half-close. 
     
    9961143 
    9971144 
    9981145class IProtocolFactory(Interface): 
    999     """Interface for protocol factories. 
    10001146    """ 
     1147    Interface for protocol factories. 
     1148    """ 
    10011149 
    10021150    def buildProtocol(addr): 
    1003         """Called when a connection has been established to addr. 
     1151        """ 
     1152        Called when a connection has been established to addr. 
    10041153 
    10051154        If None is returned, the connection is assumed to have been refused, 
    10061155        and the Port will close the connection. 
     
    10131162        """ 
    10141163 
    10151164    def doStart(): 
    1016         """Called every time this is connected to a Port or Connector.""" 
     1165        """ 
     1166        Called every time this is connected to a Port or Connector. 
     1167        """ 
    10171168 
    10181169    def doStop(): 
    1019         """Called every time this is unconnected from a Port or Connector.""" 
     1170        """ 
     1171        Called every time this is unconnected from a Port or Connector. 
     1172        """ 
    10201173 
    10211174 
    10221175class ITransport(Interface): 
    1023     """I am a transport for bytes. 
     1176    """ 
     1177    I am a transport for bytes. 
    10241178 
    10251179    I represent (and wrap) the physical connection and synchronicity 
    10261180    of the framework which is talking to the network.  I make no 
     
    10321186    """ 
    10331187 
    10341188    def write(data): 
    1035         """Write some data to the physical connection, in sequence, in a 
     1189        """ 
     1190        Write some data to the physical connection, in sequence, in a 
    10361191        non-blocking fashion. 
    10371192 
    10381193        If possible, make sure that it is all written.  No data will 
     
    10411196        """ 
    10421197 
    10431198    def writeSequence(data): 
    1044         """Write a list of strings to the physical connection. 
     1199        """ 
     1200        Write a list of strings to the physical connection. 
    10451201 
    10461202        If possible, make sure that all of the data is written to 
    10471203        the socket at once, without first copying it all into a 
     
    10491205        """ 
    10501206 
    10511207    def loseConnection(): 
    1052         """Close my connection, after writing all pending data. 
     1208        """ 
     1209        Close my connection, after writing all pending data. 
    10531210 
    10541211        Note that if there is a registered producer on a transport it 
    10551212        will not be closed until the producer has been unregistered. 
    10561213        """ 
    10571214 
    10581215    def getPeer(): 
    1059         """Get the remote address of this connection. 
     1216        """ 
     1217        Get the remote address of this connection. 
    10601218 
    10611219        Treat this method with caution.  It is the unfortunate result of the 
    10621220        CGI and Jabber standards, but should not be considered reliable for 
     
    10761234 
    10771235 
    10781236class ITCPTransport(ITransport): 
    1079     """A TCP based transport.""" 
     1237    """ 
     1238    A TCP based transport. 
     1239    """ 
    10801240 
    10811241    def loseWriteConnection(): 
    1082         """Half-close the write side of a TCP connection. 
     1242        """ 
     1243        Half-close the write side of a TCP connection. 
    10831244 
    10841245        If the protocol instance this is attached to provides 
    10851246        IHalfCloseableProtocol, it will get notified when the operation is 
     
    10891250        """ 
    10901251 
    10911252    def getTcpNoDelay(): 
    1092         """Return if TCP_NODELAY is enabled.""" 
     1253        """ 
     1254        Return if TCP_NODELAY is enabled.""" 
    10931255 
    10941256    def setTcpNoDelay(enabled): 
    1095         """Enable/disable TCP_NODELAY. 
     1257        """ 
     1258        Enable/disable TCP_NODELAY. 
    10961259 
    10971260        Enabling TCP_NODELAY turns off Nagle's algorithm. Small packets are 
    1098         sent sooner, possibly at the expense of overall throughput.""" 
     1261        sent sooner, possibly at the expense of overall throughput. 
     1262        """ 
    10991263 
    11001264    def getTcpKeepAlive(): 
    1101         """Return if SO_KEEPALIVE enabled.""" 
     1265        """ 
     1266        Return if SO_KEEPALIVE enabled. 
     1267        """ 
    11021268 
    11031269    def setTcpKeepAlive(enabled): 
    1104         """Enable/disable SO_KEEPALIVE. 
     1270        """ 
     1271        Enable/disable SO_KEEPALIVE. 
    11051272 
    11061273        Enabling SO_KEEPALIVE sends packets periodically when the connection 
    11071274        is otherwise idle, usually once every two hours. They are intended 
    1108         to allow detection of lost peers in a non-infinite amount of time.""" 
     1275        to allow detection of lost peers in a non-infinite amount of time. 
     1276        """ 
    11091277 
    11101278    def getHost(): 
    1111         """Returns L{IPv4Address}.""" 
     1279        """ 
     1280        Returns L{IPv4Address}. 
     1281        """ 
    11121282 
    11131283    def getPeer(): 
    1114         """Returns L{IPv4Address}.""" 
     1284        """ 
     1285        Returns L{IPv4Address}. 
     1286        """ 
    11151287 
    11161288 
    11171289class ITLSTransport(ITCPTransport): 
    1118     """A TCP transport that supports switching to TLS midstream. 
     1290    """ 
     1291    A TCP transport that supports switching to TLS midstream. 
    11191292 
    11201293    Once TLS mode is started the transport will implement L{ISSLTransport}. 
    11211294    """ 
    11221295 
    11231296    def startTLS(contextFactory): 
    1124         """Initiate TLS negotiation. 
     1297        """ 
     1298        Initiate TLS negotiation. 
    11251299 
    11261300        @param contextFactory: A context factory (see L{ssl.py<twisted.internet.ssl>}) 
    11271301        """ 
    11281302 
    11291303class ISSLTransport(ITCPTransport): 
    1130     """A SSL/TLS based transport.""" 
     1304    """ 
     1305    A SSL/TLS based transport. 
     1306    """ 
    11311307 
    11321308    def getPeerCertificate(): 
    1133         """Return an object with the peer's certificate info.""" 
     1309        """ 
     1310        Return an object with the peer's certificate info. 
     1311        """ 
    11341312 
    11351313 
    11361314class IProcessTransport(ITransport): 
    1137     """A process transport. 
     1315    """ 
     1316    A process transport. 
    11381317 
    11391318    @ivar pid: The Process-ID of this process. 
    11401319    """ 
    11411320 
    11421321    def closeStdin(): 
    1143         """Close stdin after all data has been written out.""" 
     1322        """ 
     1323        Close stdin after all data has been written out. 
     1324        """ 
    11441325 
    11451326    def closeStdout(): 
    1146         """Close stdout.""" 
     1327        """ 
     1328        Close stdout. 
     1329        """ 
    11471330 
    11481331    def closeStderr(): 
    1149         """Close stderr.""" 
     1332        """ 
     1333        Close stderr. 
     1334        """ 
    11501335 
    11511336    def closeChildFD(descriptor): 
    11521337        """ 
     
    11711356        """ 
    11721357 
    11731358    def loseConnection(): 
    1174         """Close stdin, stderr and stdout.""" 
     1359        """ 
     1360        Close stdin, stderr and stdout. 
     1361        """ 
    11751362 
    11761363    def signalProcess(signalID): 
    1177         """Send a signal to the process. 
     1364        """ 
     1365        Send a signal to the process. 
    11781366 
    11791367        @param signalID: can be 
    11801368          - one of C{\"HUP\"}, C{\"KILL\"}, C{\"STOP\"}, or C{\"INT\"}. 
     
    11901378 
    11911379 
    11921380class IServiceCollection(Interface): 
    1193     """An object which provides access to a collection of services.""" 
     1381    """ 
     1382    An object which provides access to a collection of services. 
     1383    """ 
    11941384 
    11951385    def getServiceNamed(serviceName): 
    1196         """Retrieve the named service from this application. 
     1386        """ 
     1387        Retrieve the named service from this application. 
    11971388 
    11981389        Raise a KeyError if there is no such service name. 
    11991390        """ 
    12001391 
    12011392    def addService(service): 
    1202         """Add a service to this collection. 
    12031393        """ 
     1394        Add a service to this collection. 
     1395        """ 
    12041396 
    12051397    def removeService(service): 
    1206         """Remove a service from this collection.""" 
     1398        """ 
     1399        Remove a service from this collection. 
     1400        """ 
    12071401 
    12081402 
    12091403class IUDPTransport(Interface): 
    1210     """Transport for UDP DatagramProtocols.""" 
     1404    """ 
     1405    Transport for UDP DatagramProtocols. 
     1406    """ 
    12111407 
    12121408    def write(packet, addr=None): 
    1213         """Write packet to given address. 
     1409        """ 
     1410        Write packet to given address. 
    12141411 
    12151412        @param addr: a tuple of (ip, port). For connected transports must 
    12161413                     be the address the transport is connected to, or None. 
     
    12211418        """ 
    12221419 
    12231420    def connect(host, port): 
    1224         """Connect the transport to an address. 
     1421        """ 
     1422        Connect the transport to an address. 
    12251423 
    12261424        This changes it to connected mode. Datagrams can only be sent to 
    12271425        this address, and will only be received from this address. In addition 
     
    12331431        """ 
    12341432 
    12351433    def getHost(): 
    1236         """Returns IPv4Address.""" 
     1434        """ 
     1435        Returns IPv4Address. 
     1436        """ 
    12371437 
    12381438    def stopListening(): 
    1239         """Stop listening on this port. 
     1439        """ 
     1440        Stop listening on this port. 
    12401441 
    12411442        If it does not complete immediately, will return Deferred that fires 
    12421443        upon completion. 
     
    12441445 
    12451446 
    12461447class IUDPConnectedTransport(Interface): 
    1247     """DEPRECATED. Transport for UDP ConnectedPacketProtocols.""" 
     1448    """ 
     1449    DEPRECATED. Transport for UDP ConnectedPacketProtocols. 
     1450    """ 
    12481451 
    12491452    def write(packet): 
    1250         """Write packet to address we are connected to.""" 
     1453        """ 
     1454        Write packet to address we are connected to. 
     1455        """ 
    12511456 
    12521457    def getHost(): 
    1253         """Returns UNIXAddress.""" 
     1458        """ 
     1459        Returns UNIXAddress. 
     1460        """ 
    12541461 
    12551462 
    12561463class IUNIXDatagramTransport(Interface): 
    1257     """Transport for UDP PacketProtocols.""" 
     1464    """ 
     1465    Transport for UDP PacketProtocols. 
     1466    """ 
    12581467 
    12591468    def write(packet, address): 
    1260         """Write packet to given address.""" 
     1469        """ 
     1470        Write packet to given address. 
     1471        """ 
    12611472 
    12621473    def getHost(): 
    1263         """Returns UNIXAddress.""" 
     1474        """ 
     1475        Returns UNIXAddress. 
     1476        """ 
    12641477 
    12651478 
    12661479class IUNIXDatagramConnectedTransport(Interface): 
    1267     """Transport for UDP ConnectedPacketProtocols.""" 
     1480    """ 
     1481    Transport for UDP ConnectedPacketProtocols. 
     1482    """ 
    12681483 
    12691484    def write(packet): 
    1270         """Write packet to address we are connected to.""" 
     1485        """ 
     1486        Write packet to address we are connected to. 
     1487        """ 
    12711488 
    12721489    def getHost(): 
    1273         """Returns UNIXAddress.""" 
     1490        """ 
     1491        Returns UNIXAddress. 
     1492        """ 
    12741493 
    12751494    def getPeer(): 
    1276         """Returns UNIXAddress.""" 
     1495        """ 
     1496        Returns UNIXAddress. 
     1497        """ 
    12771498 
    12781499 
    12791500class IMulticastTransport(Interface): 
    1280     """Additional functionality for multicast UDP.""" 
     1501    """ 
     1502    Additional functionality for multicast UDP. 
     1503    """ 
    12811504 
    12821505    def getOutgoingInterface(): 
    1283         """Return interface of outgoing multicast packets.""" 
     1506        """ 
     1507        Return interface of outgoing multicast packets. 
     1508        """ 
    12841509 
    12851510    def setOutgoingInterface(addr): 
    1286         """Set interface for outgoing multicast packets. 
     1511        """ 
     1512        Set interface for outgoing multicast packets. 
    12871513 
    12881514        Returns Deferred of success. 
    12891515        """ 
    12901516 
    12911517    def getLoopbackMode(): 
    1292         """Return if loopback mode is enabled.""" 
     1518        """ 
     1519        Return if loopback mode is enabled. 
     1520        """ 
    12931521 
    12941522    def setLoopbackMode(mode): 
    1295         """Set if loopback mode is enabled.""" 
     1523        """ 
     1524        Set if loopback mode is enabled. 
     1525        """ 
    12961526 
    12971527    def getTTL(): 
    1298         """Get time to live for multicast packets.""" 
     1528        """ 
     1529        Get time to live for multicast packets. 
     1530        """ 
    12991531 
    13001532    def setTTL(ttl): 
    1301         """Set time to live on multicast packets.""" 
     1533        """ 
     1534        Set time to live on multicast packets. 
     1535        """ 
    13021536 
    13031537    def joinGroup(addr, interface=""): 
    1304         """Join a multicast group. Returns Deferred of success or failure. 
     1538        """ 
     1539        Join a multicast group. Returns Deferred of success or failure. 
    13051540 
    13061541        If an error occurs, the returned Deferred will fail with 
    13071542        L{error.MulticastJoinError}. 
    13081543        """ 
    13091544 
    13101545    def leaveGroup(addr, interface=""): 
    1311         """Leave multicast group, return Deferred of success.""" 
     1546        """ 
     1547        Leave multicast group, return Deferred of success. 
     1548        """ 
     1549