Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/library/asynchat.rst

    r2 r391  
    1 
    21:mod:`asynchat` --- Asynchronous socket command/response handler
    32================================================================
     
    87.. sectionauthor:: Steve Holden <sholden@holdenweb.com>
    98
     9**Source code:** :source:`Lib/asynchat.py`
     10
     11--------------
    1012
    1113This module builds on the :mod:`asyncore` infrastructure, simplifying
     
    3335   Like :class:`asyncore.dispatcher`, :class:`async_chat` defines a set of
    3436   events that are generated by an analysis of socket conditions after a
    35    :cfunc:`select` call. Once the polling loop has been started the
     37   :c:func:`select` call. Once the polling loop has been started the
    3638   :class:`async_chat` object's methods are called by the event-processing
    3739   framework with no action on the part of the programmer.
     
    8284
    8385
    84 .. method:: async_chat._collect_incoming_data(data)
    85 
    86    Sample implementation of a data collection rutine to be used in conjunction
    87    with :meth:`_get_data` in a user-specified :meth:`found_terminator`.
    88 
    89 
    9086.. method:: async_chat.discard_buffers()
    9187
     
    10298
    10399
    104 .. method:: async_chat._get_data()
    105 
    106    Will return and clear the data received with the sample
    107    :meth:`_collect_incoming_data` implementation.
    108 
    109 
    110100.. method:: async_chat.get_terminator()
    111101
     
    113103
    114104
    115 .. method:: async_chat.handle_close()
    116 
    117    Called when the channel is closed. The default method silently closes the
    118    channel's socket.
    119 
    120 
    121 .. method:: async_chat.handle_read()
    122 
    123    Called when a read event fires on the channel's socket in the asynchronous
    124    loop.  The default method checks for the termination condition established
    125    by :meth:`set_terminator`, which can be either the appearance of a
    126    particular string in the input stream or the receipt of a particular number
    127    of characters.  When the terminator is found, :meth:`handle_read` calls the
    128    :meth:`found_terminator` method after calling :meth:`collect_incoming_data`
    129    with any data preceding the terminating condition.
    130 
    131 
    132 .. method:: async_chat.handle_write()
    133 
    134    Called when the application may write data to the channel.   The default
    135    method calls the :meth:`initiate_send` method, which in turn will call
    136    :meth:`refill_buffer` to collect data from the producer fifo associated
    137    with the channel.
    138 
    139 
    140105.. method:: async_chat.push(data)
    141106
    142    Creates a :class:`simple_producer` object (*see below*) containing the data
    143    and pushes it on to the channel's ``producer_fifo`` to ensure its
    144    transmission.  This is all you need to do to have the channel write the
    145    data out to the network, although it is possible to use your own producers
    146    in more complex schemes to implement encryption and chunking, for example.
     107   Pushes data on to the channel's fifo to ensure its transmission.
     108   This is all you need to do to have the channel write the data out to the
     109   network, although it is possible to use your own producers in more complex
     110   schemes to implement encryption and chunking, for example.
    147111
    148112
     
    155119
    156120
    157 .. method:: async_chat.readable()
    158 
    159    Should return ``True`` for the channel to be included in the set of
    160    channels tested by the :cfunc:`select` loop for readability.
    161 
    162 
    163 .. method:: async_chat.refill_buffer()
    164 
    165    Refills the output buffer by calling the :meth:`more` method of the
    166    producer at the head of the fifo.  If it is exhausted then the producer is
    167    popped off the fifo and the next producer is activated.  If the current
    168    producer is, or becomes, ``None`` then the channel is closed.
    169 
    170 
    171121.. method:: async_chat.set_terminator(term)
    172122
     
    193143
    194144
    195 .. method:: async_chat.writable()
    196 
    197    Should return ``True`` as long as items remain on the producer fifo, or the
    198    channel is connected and the channel's output buffer is non-empty.
    199 
    200 
    201 asynchat - Auxiliary Classes and Functions
     145asynchat - Auxiliary Classes
    202146------------------------------------------
    203147
    204 
    205 .. class:: simple_producer(data[, buffer_size=512])
    206 
    207    A :class:`simple_producer` takes a chunk of data and an optional buffer
    208    size.  Repeated calls to its :meth:`more` method yield successive chunks of
    209    the data no larger than *buffer_size*.
    210 
    211 
    212    .. method:: more()
    213 
    214       Produces the next chunk of information from the producer, or returns the
    215       empty string.
    216 
    217 
    218148.. class:: fifo([list=None])
    219149
    220    Each channel maintains a :class:`fifo` holding data which has been pushed
    221    by the application but not yet popped for writing to the channel.  A
    222    :class:`fifo` is a list used to hold data and/or producers until they are
    223    required.  If the *list* argument is provided then it should contain
    224    producers or data items to be written to the channel.
     150   A :class:`fifo` holding data which has been pushed by the application but
     151   not yet popped for writing to the channel.  A :class:`fifo` is a list used
     152   to hold data and/or producers until they are required.  If the *list*
     153   argument is provided then it should contain producers or data items to be
     154   written to the channel.
    225155
    226156
     
    245175      If the fifo is not empty, returns ``True, first()``, deleting the popped
    246176      item.  Returns ``False, None`` for an empty fifo.
    247 
    248 The :mod:`asynchat` module also defines one utility function, which may be of
    249 use in network and textual analysis operations.
    250 
    251 
    252 .. function:: find_prefix_at_end(haystack, needle)
    253 
    254    Returns ``True`` if string *haystack* ends with any non-empty prefix of
    255    string *needle*.
    256177
    257178
Note: See TracChangeset for help on using the changeset viewer.