Current Path : /usr/lib/python2.7/dist-packages/twisted/internet/ |
Current File : //usr/lib/python2.7/dist-packages/twisted/internet/abstract.pyc |
˪Nc @ s d Z d d l m Z d d l m Z m Z d d l m Z m Z d e f d YZ d e f d YZ d e e f d YZ d Z d g Z d S( s+ Support for generic select()able objects. i( t implements( t reflectt failure( t interfacest maint _ConsumerMixinc B s; e Z d Z d Z e Z e Z d Z d Z d Z RS( s L{IConsumer} implementations can mix this in to get C{registerProducer} and C{unregisterProducer} methods which take care of keeping track of a producer's state. Subclasses must provide three attributes which L{_ConsumerMixin} will read but not write: - connected: A C{bool} which is C{True} as long as the the consumer has someplace to send bytes (for example, a TCP connection), and then C{False} when it no longer does. - disconnecting: A C{bool} which is C{False} until something like L{ITransport.loseConnection} is called, indicating that the send buffer should be flushed and the connection lost afterwards. Afterwards, C{True}. - disconnected: A C{bool} which is C{False} until the consumer no longer has a place to send bytes, then C{True}. Subclasses must also override the C{startWriting} method. @ivar producer: C{None} if no producer is registered, otherwise the registered producer. @ivar producerPaused: A flag indicating whether the producer is currently paused. @type producerPaused: C{bool} or C{int} @ivar streamingProducer: A flag indicating whether the producer was registered as a streaming (ie push) producer or not (ie a pull producer). This will determine whether the consumer may ever need to pause and resume it, or if it can merely call C{resumeProducing} on it when buffer space is available. @ivar streamingProducer: C{bool} or C{int} c C s t d d S( s Override in a subclass to cause the reactor to monitor this selectable for write events. This will be called once in C{unregisterProducer} if C{loseConnection} has previously been called, so that the connection can actually close. s! %r did not implement startWritingN( t NotImplementedError( t self( ( s= /usr/lib/python2.7/dist-packages/twisted/internet/abstract.pyt startWriting; s c C sj | j d k r+ t d | | j f n | j rA | j n% | | _ | | _ | sf | j n d S( s" Register to receive data from a producer. This sets this selectable to be a consumer for a producer. When this selectable runs out of data on a write() call, it will ask the producer to resumeProducing(). When the FileDescriptor's internal data buffer is filled, it will ask the producer to pauseProducing(). If the connection is lost, FileDescriptor calls producer's stopProducing() method. If streaming is true, the producer should provide the IPushProducer interface. Otherwise, it is assumed that producer provides the IPullProducer interface. In this case, the producer won't be asked to pauseProducing(), but it has to be careful to write() data only when its resumeProducing() method is called. sH Cannot register producer %s, because producer %s was never unregistered.N( t producert Nonet RuntimeErrort disconnectedt stopProducingt streamingProducert resumeProducing( R R t streaming( ( s= /usr/lib/python2.7/dist-packages/twisted/internet/abstract.pyt registerProducerE s c C s, d | _ | j r( | j r( | j n d S( sM Stop consuming data from a producer, without disconnecting. N( R R t connectedt disconnectingR ( R ( ( s= /usr/lib/python2.7/dist-packages/twisted/internet/abstract.pyt unregisterProducerb s N( t __name__t __module__t __doc__R R t Falset producerPausedR R R R ( ( ( s= /usr/lib/python2.7/dist-packages/twisted/internet/abstract.pyR s % t _LogOwnerc B s- e Z d Z e e j d Z d Z RS( s Mixin to help implement L{interfaces.ILoggingContext} for transports which have a protocol, the log prefix of which should also appear in the transport's log prefix. c C s&