Ϫf 3dZddlZddlmZddlmZmZmZddlm Z m Z m Z ddl m ZddlmZmZddlmZeej(ej*ej,ej.Gd d e e Zd gZy) z Abstract file handle class N) implementer)error interfacesmain)_ConsumerMixin_dataMustBeBytes _LogOwner) iocpsupport)ERROR_HANDLE_EOFERROR_IO_PENDING)failurecZeZdZdZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+d Z,d!Z-d,d"Z.d#Z/d$Z0e1jde3jhfd%Z5d&Z6d'Z7d(Z8d)Z9d*Z:d+Z;y)- FileHandlez< File handle that can read and write asynchronously iFTrNc|jj||js@|js3d|_|jj d|j |_yyyNTr)reactoraddActiveHandle_readScheduledreading callLater_resumeReadingselfs G/usr/lib/python3/dist-packages/twisted/internet/iocpreactor/abstract.py startReadingzFileHandle.startReading(sQ $$T*""4<<DL"&,,"8"8D>Q& &&''1, ,,!DN%%' 'rctj|j|}|jx|_}|j ||\}}|r |t k(rd|_y|j|||yNT) _iocpEventr>r.buffreadFromHandler r%r9)rr=rRr; numBytesReads rr&zFileHandle.doRead{sdkk$,,-+++4..tS9LR++&*D #   Rs 3rctr#NotImplementedError)rbufflistr=s rrSzFileHandle.readFromHandle !##rctr#rVrr<s rr-zFileHandle.dataReceiveds!!rc&|j|yr#rJrreasons rrGzFileHandle.readConnectionLosts F#rric2d|_|jyrO)_writeDisconnecting startWritingrs rloseWriteConnectionzFileHandle.loseWriteConnections#'  rcyr#rs r_closeWriteConnectionz FileHandle._closeWriteConnections rc&|j|yr#r]r^s rwriteConnectionLostzFileHandle.writeConnectionLosts F#rc|jj||js@|js3d|_|jj d|j |_yyyr)rr_writeScheduledwritingr_resumeWritingrs rrbzFileHandle.startWritingsQ $$T*##DLLDL#'<<#9#9!T=P=P#QD -9#rcl|jr!|jjd|_d|_yr)rjr rkrs r stopWritingzFileHandle.stopWritings,     ' ' )#'D  rc2d|_|jyr#)rjdoWriters rrlzFileHandle._resumeWritings# rcL|j|||r|jyyr#) _handleWriterprr;numBytesWrittenr=s r_cbWritezFileHandle._cbWrites"   R# 6 LLN 7rc |js |jry|r]|jtjt j dtjj|dd|dy|xj|z c_ |jt|jk(r|jsd|_ d|_ |j|j:|j r |j"r"d|_|jj%y|j&r3|jtjt(j*y|j,rd|_|j/yy) zA Returns false if we should stop writing for now Fzwrite error -- r@rArBrrT)rC_writeDisconnectedrJr rHrrKrDrLrMoffsetr0 dataBuffer _tempDataLenrnproducerstreamingProducerproducerPausedresumeProducing disconnectingrrIrarfrss rrrzFileHandle._handleWrites9    7 7    (( ??..r9=rC  KK? *K{{c$//224;L;L"%   "==,//D4G4G+/D'MM113''''8L8L(MN  --.2D+..0rc@t|j|jz |jkrO|j|jddj |j z|_d|_g|_d|_tj|j|}|jr,t|j}||jdx|_ }n|jx|_ }|j||\}}|r|tk7r|j|||yyy)Nrr)r0ryrx SEND_LIMITjoin_tempDataBufferrzrPrQru memoryviewrR writeToHandler rr)rr=sendViewrRr;r<s rrpzFileHandle.doWrites t $++ - ?#oodkkmR>RR*.D'MM002     rc|D] }t||jr|r |jry|jj ||D] }|xj t |z c_"|j\|jrPt |j|j z|jkDr!d|_ |jj|jyrO)rrrwrextendrzr0r{r|ryrr}rrb)riovecis r writeSequencezFileHandle.writeSequences A Q  ~~Ud.E.E  ##E* (A   Q '  ( == $)?)?4??#d&7&77$:N:NN&*# ,,. r Uninitializedict|sddlm}||_g|_d|_t |j g|_y)Nr)r)twisted.internetrrrzr3r+r.)rrs r__init__zFileHandle.__init__'s5 0 !&t':':;<rcd|_d|_|j!|jjd|_|j |j |j j|y)a 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. TFN)rCrr{ stopProducingr!rnrrFr^s rrJzFileHandle.connectionLost/s^! == $ MM ' ' ) DM   ''-rcy)Nr)rers r getFileHandlezFileHandle.getFileHandleDsrc|jro|jsb|jr.|j|j|j |y|j|j d|_yyy)ad 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. r(N)rrrwr!rnrJrb)r _connDones rloseConnectionzFileHandle.loseConnectionGsf >>$"4"4&&  "  ##I.  "!!#%&"#5>rcD|j|jy)z 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)unregisterProducerrrs r stopConsumingzFileHandle.stopConsumingcs ! rcX|jr|js|jyyyr#)rrrrs rr~zFileHandle.resumeProducingps$ >>$"4"4    #5>rc$|jyr#)r!rs rrzFileHandle.pauseProducingts rc$|jyr#)rrs rrzFileHandle.stopProducingws rctr#rVrs rgetHostzFileHandle.getHostz !##rctr#rVrs rgetPeerzFileHandle.getPeer~rrr#)<__name__ __module__ __qualname____doc__r1r+rr/r,r*rr%rr!rr$r>r9r&rSr-rGryrxrkrjrarwrrcrfrhrbrnrlrurrrprrrrrCrlogstrrrrJrr rHrrIrrr~rrrrrerrrrs/ NNGOINQ   @ (: 4$"$J FGO O $R +Z-.$ " ILM FJ=.*(7wt7K7K'L'8  $$rr)rrDzope.interfacerrrrrtwisted.internet.abstractrrr twisted.internet.iocpreactorr rP"twisted.internet.iocpreactor.constr r twisted.pythonr IPushProducer IConsumer ITransportIHalfCloseableDescriptorr__all__rerrrsz &44QQ=Q" ''  g$g$  g$T .r