Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyc


˪Nc@sdZddlmZmZmZddlmZmZddlm	Z	ddl
mZddlZddl
mZddl
mZdd	lmZd
eefdYZd
gZdS(s
Abstract file handle class
i(tmainterrort
interfaces(t_ConsumerMixint	_LogOwner(tfailure(t
implementsN(tERROR_HANDLE_EOF(tERROR_IO_PENDING(tiocpsupportt
FileHandlecBseZdZeejejejejdZ	dZ
eZe
ZdZdZd'ZeZdZdZdZdZdZd	Zd
ZdZdZd
ZdZdZeZ d'Z!eZ"eZ#ddd(Z$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0eZ1eZ2eZ3dZ4d)Z5d'dZ6d Z7d!Z8e9j:e;j<d"Z=d#Z>d$Z?d%Z@d&ZARS(*s<
    File handle that can read and write asynchronously
    iiicCsO|jj||jrK|jrKt|_|jjd|j|_ndS(Ni(treactortaddActiveHandlet_readScheduledtreadingtTruet	callLatert_resumeReading(tself((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pytstartReading&s
	cCs/|jr"|jjd|_nt|_dS(N(R
tcanceltNonetFalseR(R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pytstopReading.s	
cCs0d|_|jr,|jr,|jndS(N(RR
t
_dispatchDatat_readScheduledInOStdoRead(R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyR5s	cCsC|js|jS|j}||j}xF|j|krn|j|j|j|jd7_|js)tSq)W||j}|r|jt|j|d|n|jr*|jt	|j}|||jkr|jd=q*||kr*t	|j|j
kr*|jjtj
|jq*nd|_d|_|jS(st
        Dispatch previously read data. Return True if self.reading and we don't
        have any more data
        iii(t	_readSizeRtreadBufferSizet_readNextBuffertdataReceivedt_readBuffersRtbuffertdynamicReadBufferstlentmaxReadBufferstappendt_iocptAllocateReadBuffer(Rtsizetfull_bufferst	remainderttotal_buffer_size((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyR;s0		
	
	
		cCs/t|_|j|||r+|jndS(N(RRt_handleReadR(Rtrctbytestevt((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyt_cbRead\s	c	Cs|jr
tS|p|s/|tjtfkr\|jj||jtj	t
jtS|r|jtj	t
jdtjj|d|ftS|jdkst|jdkst||_|jSdS(sA
        Returns False if we should stop reading for now
        sread error -- %s (%s)tunknowniN(tdisconnectedRterrnot
WSAEDISCONRRtremoveActiveHandletreadConnectionLostRtFailureRtCONNECTION_DONEtconnectionLostRtConnectionLostt	errorcodetgetRtAssertionErrorRR(RR,R-R.((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyR+bs	"	#	cCsstj|j|}|j|_}|j||\}}|sP|tkr\t|_n|j	|||dS(N(
R%tEventR/RtbufftreadFromHandleRRRR+(RR.R>R,R-((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyR{scCs
tdS(N(tNotImplementedError(RtbufflistR.((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyR?scCs
tdS(N(R@(Rtdata((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyRscCs|j|dS(N(R8(Rtreason((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyR5sticCst|_|jdS(N(Rt_writeDisconnectingtstartWriting(R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pytloseWriteConnections	cCsdS(N((R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyt_closeWriteConnectionscCs|j|dS(N(R8(RRC((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pytwriteConnectionLostscCsD|jj|t|_|js@|jjd|j|_ndS(Ni(RRRtwritingt_writeScheduledRt_resumeWriting(R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyRFs
		cCs/|jr"|jjd|_nt|_dS(N(RKRRRRJ(R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pytstopWritings	
cCsd|_|jdS(N(RRKtdoWrite(R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyRLs	cCs&|j|||r"|jndS(N(t_handleWriteRN(RR,R-R.((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyt_cbWritescCs0|js|jrtS|rX|jtjtjdtj	j
|d|ftS|j|7_|jt|j
kr(|jr(d|_
d|_|j|jdk	r|js|jrt|_|jjnD|jr|jtjtjn|jr$|jt|_ntStSdS(sA
        Returns false if we should stop writing for now
        swrite error -- %s (%s)R0RDiN(R1t_writeDisconnectedRR8RR6RR9R2R:R;toffsetR"t
dataBuffert_tempDataLenRMtproducerRtstreamingProducertproducerPausedRtresumeProducingt
disconnectingRR7RERH(RR,R-R.((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyROs.	#"		
				
cCst|j|j|jkret|j|jdj|j|_d|_g|_d|_ntj	|j
|}|jrt|j|j|_}n|j|_}|j||\}}|r|t
kr|j|||ndS(NRDi(R"RSRRt
SEND_LIMITR tjoint_tempDataBufferRTR%R=RPR>t
writeToHandleRRO(RR.R>R,R-((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyRNs			cCs
tdS(N(R@(RR>R.((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyR]scCst|trtdn|js1|jr5dS|r|jj||jt|7_|j	dk	r|jrt|j|j|j
krt|_|j	jqn|jndS(spReliably write some data.

        The data is buffered until his file descriptor is ready for writing.
        sData must not be unicodeN(t
isinstancetunicodet	TypeErrort	connectedRQR\R$RTR"RURRVRStwriteBufferSizeRRWtpauseProducingRF(RRB((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pytwrites	cCsx,|D]$}t|trtdqqW|jsI|sI|jrMdS|jj|x#|D]}|jt|7_qdW|j	dk	r|jrt|j|j|j
krt|_|j	jqn|jdS(NsData must not be unicode(R^R_R`RaRQR\textendRTR"RURRVRSRbRRWRcRF(Rtiovecti((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyt
writeSequences

	t
UninitializediicCsP|sddlm}n||_g|_d|_tj|jg|_dS(Ni(Ri(ttwisted.internetRR\RTR%R&RR(RR((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyt__init__4s			cCsbt|_t|_|jdk	r:|jjd|_n|j|j|j	j
|dS(s
        The connection was lost.

        This is called when the connection on a selectable object has been
        lost.  It will be called whether the connection was closed explicitly,
        an exception occurred in an event handler, or the other end of the
        connection closed it first.

        Clean up state here, but make sure to call back up to FileDescriptor.
        N(RR1RRaRURt
stopProducingRRMRR4(RRC((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyR8=s		


cCsdS(Ni((R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyt
getFileHandleSscCsa|jr]|jr]|jr=|j|j|j|q]|j|jd|_ndS(sd
        Close the connection at the next available opportunity.

        Call this to cause this FileDescriptor to lose its connection.  It will
        first write any data that it has buffered.

        If there is data buffered yet to be written, this method will cause the
        transport to lose its connection as soon as it's done flushing its
        write buffer.  If you have a producer registered, the connection won't
        be closed until the producer is finished. Therefore, make sure you
        unregister your producer when it's finished, or the connection will
        never close.
        iN(RaRYRQRRMR8RF(Rt	_connDone((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pytloseConnectionWs	


cCs|j|jdS(s
        Stop consuming data.

        This is called when a producer has lost its connection, to tell the
        consumer to go lose its connection (and break potential circular
        references).
        N(tunregisterProducerRo(R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyt
stopConsumingts
cCs'|jr|jst|jdS(N(RaRYR<R(R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyRXscCs|jdS(N(R(R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyRcscCs|jdS(N(Ro(R((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyRlsNii(Bt__name__t
__module__t__doc__RRt	IProducert	IConsumert
ITransporttIHalfCloseableDescriptorR#RRRRR!RRRR
RRRRRR/R+RR?RR5RSRRRJRKRERQRbRGRHRIRFRMRLRPRORNR]RdRhRaR1RYtlogstrRZRkR8RmRR6RR7RoRqRXRcRl(((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyR
sj				!														(										(RtRjRRRttwisted.internet.abstractRRttwisted.pythonRtzope.interfaceRR2t"twisted.internet.iocpreactor.constRRttwisted.internet.iocpreactorR	R%R
t__all__(((sI/usr/lib/python2.7/dist-packages/twisted/internet/iocpreactor/abstract.pyt<module>s{