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/pollreactor.pyc

ó
H!¯Nc@sÈdZddlZddlmZmZddlmZmZmZm	Z	m
Z
ddlmZddl
mZddlmZddlmZd	ejejfd
„ƒYZd„Zd	dgZdS(
sñ
A poll() based implementation of the twisted main loop.

To install the event loop (and you should do this before any connections,
listeners or connectors are added)::

    from twisted.internet import pollreactor
    pollreactor.install()
iÿÿÿÿN(terrortpoll(tPOLLINtPOLLOUTtPOLLHUPtPOLLERRtPOLLNVAL(t
implements(tlog(t	posixbase(t
IReactorFDSettPollReactorcBs›eZdZeeƒeeBeBZe	Z
eZd„Z
d„Zd„Zd„Zd„Zd„Zd„Zd„Zd	„ZeZd
„Zd„ZRS(sW
    A reactor that uses poll(2).

    @ivar _poller: A L{poll} which will be used to check for I/O
        readiness.

    @ivar _selectables: A dictionary mapping integer file descriptors to
        instances of L{FileDescriptor} which have been registered with the
        reactor.  All L{FileDescriptors} which are currently receiving read or
        write readiness notifications will be present as values in this
        dictionary.

    @ivar _reads: A dictionary mapping integer file descriptors to arbitrary
        values (this is essentially a set).  Keys in this dictionary will be
        registered with C{_poller} for read readiness notifications which will
        be dispatched to the corresponding L{FileDescriptor} instances in
        C{_selectables}.

    @ivar _writes: A dictionary mapping integer file descriptors to arbitrary
        values (this is essentially a set).  Keys in this dictionary will be
        registered with C{_poller} for write readiness notifications which will
        be dispatched to the corresponding L{FileDescriptor} instances in
        C{_selectables}.
    cCs;tƒ|_i|_i|_i|_tjj|ƒdS(so
        Initialize polling object, file descriptor tracking dictionaries, and
        the base class.
        N(Rt_pollert_selectablest_readst_writesR	tPosixReactorBaset__init__(tself((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pyR;s
			cCs¨y|jj|ƒWntk
r'nXd}||jkrJ|tB}n||jkrf|tB}n|dkrˆ|jj||ƒn||jkr¤|j|=ndS(s*Register/unregister an fd with the poller.iN(	Rt
unregistertKeyErrorRRRRtregisterR
(Rtfdtmask((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pyt_updateRegistrationGs


cCs}y|jƒ}||Wn;x5|jjƒD]\}}||kr.Pq.q.WdSnX||kry||=|j|ƒndS(N(tfilenoR
titemsR(Rt
selectabletmdictRtfdes((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pyt_dictRemoveYscCsI|jƒ}||jkrE||j|<d|j|<|j|ƒndS(sIAdd a FileDescriptor for notification of data available to read.
        iN(RRR
R(RtreaderR((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pyt	addReaderns


cCsI|jƒ}||jkrE||j|<d|j|<|j|ƒndS(sJAdd a FileDescriptor for notification of data available to write.
        iN(RRR
R(RtwriterR((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pyt	addWriterws


cCs|j||jƒS(sHRemove a Selectable for notification of data available to read.
        (RR(RR((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pytremoveReader€scCs|j||jƒS(sIRemove a Selectable for notification of data available to write.
        (RR(RR!((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pytremoveWriter…scCsJ|jg|jD]}|j|^qg|jD]}|j|^q0ƒS(sD
        Remove all selectables, and return a list of them.
        (t
_removeAllRR
R(RR((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pyt	removeAllŠs cCsÍ|dk	rt|dƒ}ny|jj|ƒ}Wn0tk
rg}|jdtjkradS‚nX|j}xU|D]M\}}y|j	|}Wnt
k
r«qxnXtj|||||ƒqxWdS(sPoll the poller for new events.ièiN(
tNonetintRRtSelectErrortargsterrnotEINTRt_doReadOrWriteR
RRtcallWithLogger(Rttimeouttltet_drdwRteventR((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pytdoPoll“s	
cCs!g|jD]}|j|^q
S(N(RR
(RR((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pyt
getReaders«scCs!g|jD]}|j|^q
S(N(RR
(RR((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pyt
getWriters¯s(t__name__t
__module__t__doc__RR
RRRt_POLL_DISCONNECTEDRt_POLL_INRt	_POLL_OUTRRRR R"R#R$R&R4tdoIterationR5R6(((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pyRs"
													cCs'tƒ}ddlm}||ƒdS(sInstall the poll() reactor.iÿÿÿÿ(tinstallReactorN(Rttwisted.internet.mainR>(tpR>((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pytinstall´s	RA(R9R+tselectRR)RRRRRRtzope.interfaceRttwisted.pythonRttwisted.internetR	ttwisted.internet.interfacesR
Rt_PollLikeMixinRRAt__all__(((s@/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.pyt<module>s(˜