Your IP : 172.28.240.42


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


[XMc@sdZddlmZddlmZmZdZdZdddYZddd	YZ	dd
l
Z
dd
lZdd
lZdd
l
Z
defdYZdZdefdYZd
S(s
Implements a simple polling interface for file descriptors that don't work with
select() - this is pretty much only useful on Windows.
i(t
implements(t	IConsumert
IPushProducerg&.>g?t_PollableResourcecBs eZeZdZdZRS(cCs
t|_dS(N(tTruetactive(tself((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pytactivatescCs
t|_dS(N(tFalseR(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyt
deactivates(t__name__t
__module__RRRR	(((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyRs	t
_PollingTimercBsYeZdZdZdZdZdZdZdZdZ	dZ
RS(	cCs1||_g|_d|_t|_t|_dS(N(treactort
_resourcestNonet
_pollTimertMAX_TIMEOUTt_currentTimeoutRt_paused(RR
((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyt__init__#s
				cCs|jj||jdS(N(Rtappendt_checkPollingState(Rtres((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyt_addPollableResource*scCs9x2|jD]}|jr
|jPq
q
W|jdS(N(RRt
_startPollingt_stopPolling(Rtresource((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyR.s
	
cCs%|jdkr!|j|_ndS(N(RRt_reschedule(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyR6scCs,|jdk	r(|jjd|_ndS(N(RRtcancel(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyR:s
cCs
t|_dS(N(RR(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyt_pause?scCst|_|jdS(N(RRR(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyt_unpauseBs	cCs&|js"|jj|j|jSdS(N(RR
t	callLaterRt
_pollEvent(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyRFs	cCsd}g}xF|jD];}|jr||j7}|jrQ|j|qQqqW|j}|r|j|d}|tkrt}qn"|jd}|tkrt}n||_|r|j|_ndS(Ngg?g@(	RRt	checkWorkRRtMIN_TIMEOUTRRR(Rt	workUnitst	anyActiveRt
newTimeout((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyR!Js$			
		(R
RRRRRRRRRR!(((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyR s								Nt_PollableReadPipecBsQeZeedZdZdZdZdZdZ	dZ
RS(cCs||_||_||_dS(N(tpipetreceivedCallbacktlostCallback(RR(R)R*((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyRns		c	Csd}g}xxyWtj|jd\}}}|s:Pntj|j|d\}}|j|Wqtjk
rd}PqXqdj	|}|r|j
|n|r|jnt|S(Niit(
t	win32pipet
PeekNamedPipeR(t	win32filetReadFileRRtwin32apiterrortjoinR)tcleanuptlen(	RtfinishedtfullDataReadtbuffertbytesToReadtresultthrtdatatdataBuf((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyR"ts$
cCs|j|jdS(N(R	R*(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyR3s
cCs/ytj|jWntjk
r*nXdS(N(R0tCloseHandleR(t
pywintypesR1(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pytclosescCs|jdS(N(R?(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyt
stopProducingscCs|jdS(N(R	(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pytpauseProducingscCs|jdS(N(R(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pytresumeProducings(R
RRRRR"R3R?R@RARB(((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyR'js
						i@it_PollableWritePipecBsleZeedZdZdZdZdZdZ	dZ
dZdZd	Z
RS(
cCswt|_d|_d|_d|_g|_||_||_yt	j
|t	jddWntj
k
rrnXdS(Ni(Rt
disconnectingRtproducertproducerPausedtstreamingProducertoutQueuet	writePipeR*R,tSetNamedPipeHandleStatetPIPE_NOWAITR>R1(RRIR*((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyRs								cCs
t|_dS(N(RRD(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyR?scCs,|jdk	r(d|_|jjndS(Ni(RERRFRA(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyt
bufferFulls	cCsC|jdk	r?|js"|jr?d|j_|jjtStS(Ni(RERRGRFRBRR(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pytbufferEmptys	
cCsj|jdk	r+td||jfn|jsA|jn%||_||_|sf|jndS(swRegister 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(). A producer should implement the IProducer
        interface.

        FileDescriptor provides some infrastructure for producer methods.
        sHCannot register producer %s, because producer %s was never unregistered.N(RERtRuntimeErrorRR@RGRB(RREt	streaming((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pytregisterProducers
	
		cCs
d|_dS(sDStop consuming data from a producer, without disconnecting.
        N(RRE(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pytunregisterProducerscCsC|jytj|jWntjk
r4nX|jdS(N(R	R0R=RIR>R1R*(R((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pytwriteConnectionLosts
cCs|jj|dS(N(RHtextend(Rtseq((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyt
writeSequencescCsL|jr
dS|jj|ttt|jtkrH|jndS(N(RDRHRtsumtmapR4tFULL_BUFFER_SIZERL(RR;((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pytwrites
	cCsSd}|jse|jr&|jdSytj|jddWqetjk
ra|j|SXnx|jr%|jj	d}d}t
|trtdny"tj|j|d\}}Wnt
jk
r|jPqhX||7}t||krh|jjd||PqhqhW|j}|rO|jrO|jn|S(NiR+sunicode not allowed(RHRDRRR.t	WriteFileRIRR>R1tpopt
isinstancetunicodet	TypeErrorR0R4tinsertRM(RtnumBytesWrittenR;terrCodet
nBytesWrittentresumed((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyR"s:		




(R
RRRRR?RLRMRPRQRRRURYR"(((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyRCs
				
						((i(t__doc__tzope.interfaceRttwisted.internet.interfacesRRR#RRRR,R.R0R>R'RXRC(((sA/usr/lib/python2.7/dist-packages/twisted/internet/_pollingfile.pyt<module>sE6