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

ó
±ZOc@sådZddlZddlmZmZmZddlmZddlm	Z	m
Z
ddlmZddl
mZdefd	„ƒYZd
ejfd„ƒYZdeejejfd
„ƒYZdeejfd„ƒYZdS(sC
This module provides base support for Twisted to interact with the glib/gtk
mainloops.

The classes in this module should not be used directly, but rather you should
import gireactor or gtk3reactor for GObject Introspection based applications,
or glib2reactor or gtk2reactor for applications using legacy static bindings.
iÿÿÿÿN(tbaset	posixbaset
selectreactor(t
IReactorFDSet(tlogtruntime(tset(t
implementstGlibSignalMixincBs#eZejdkr!d„ZnRS(tposixcsxddlm‰tjjˆƒtjtj‡‡fd†ƒttddƒdk	rmtj	tjt
ƒnˆƒdS(Niÿÿÿÿ(treapAllProcessescs
ˆjˆƒS(N(tcallFromThread(ta(tselft_reapAllProcesses(s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt<lambda>'stsiginterrupt(ttwisted.internet.processR
Rt_SignalReactorMixint_handleSignalstsignaltSIGCHLDtgetattrtNoneRtFalse(R
((R
Rs>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyRs(t__name__t
__module__RtplatformTypeR(((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyRst	GlibWakercBseZdZd„ZRS(s/
    Run scheduled events after waking up.
    cCs!tjj|ƒ|jjƒdS(N(Rt
_UnixWakertdoReadtreactort	_simulate(R
((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyR5s(RRt__doc__R(((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyR0stGlibReactorBasecBsÒeZdZeeƒeZed„Zd„Z	d„Z
d„Zd„Zd„Z
d„Zd„Zd	„Zd
„Zd„Zd„Zd
d„Zd„Zd„Zed„Zd„Zd„Zd„ZRS(s;
    Base class for GObject event loop reactors.

    Notification for I/O events (reads and writes on file descriptors) is done
    by the the gobject-based event loop. File descriptors are registered with
    gobject with the appropriate flags for read/write/disconnect notification.

    Time-based events, the results of C{callLater} and C{callFromThread}, are
    handled differently. Rather than registering each event with gobject, a
    single gobject timeout is registered for the earliest scheduled event, the
    output of C{reactor.timeout()}. For example, if there are timeouts in 1, 2
    and 3.4 seconds, a single timeout is registered for 1 second in the
    future. When this timeout is hit, C{_simulate} is called, which calls the
    appropriate Twisted-level handlers, and a new timeout is added to gobject
    by the C{_reschedule} method.

    To handle C{callFromThread} events, we use a custom waker that calls
    C{_simulate} whenever it wakes up.

    @ivar _sources: A dictionary mapping L{FileDescriptor} instances to
        GSource handles.

    @ivar _reads: A set of L{FileDescriptor} instances currently monitored for
        reading.

    @ivar _writes: A set of L{FileDescriptor} instances currently monitored for
        writing.

    @ivar _simtag: A GSource handle for the next L{simulate} call.
    csdˆ_tƒˆ_tƒˆ_iˆ_|ˆ_|ˆ_tj	j
ˆƒˆjjˆ_ˆjj
ˆ_‡fd†}|r¸ˆjjˆ_ˆjjˆ_|ˆ_ˆjjˆ_ncˆjjƒˆ_ˆjjˆ_ˆjjˆ_ˆjjƒˆ_‡fd†ˆ_ˆjjˆ_dS(Ncs#ˆjjƒrˆjjƒndS(N(t_gtkt
main_levelt	main_quit((R
(s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt	_mainquitmscsˆjjˆjjƒS(N(t_glibtidle_addtlooptquit((R
(s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyR{s(Rt_simtagRt_readst_writest_sourcesR'R#RtPosixReactorBaset__init__t
source_removet_source_removettimeout_addt_timeout_addtevents_pendingt_pendingtmain_iteration_dot
_iterationt_crashtmaint_runtmain_context_defaulttcontexttpendingt	iterationtMainLoopR)trun(R
tglib_modulet
gtk_moduletuseGtkR&((R
s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyR0as*					cCsTt|dƒr:||d„}|jj|jƒ||ƒS|jj|||ƒSdS(NtfilenocSs
|||ƒS(N((tsourcet	conditiontreal_streal_cb((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pytwrapper‹s(thasattrR'tio_add_watchRE(R
RFRGtcallbackRJ((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt	input_addˆscCs tj||j|||ƒtS(s@
        Called by event loop when an I/O event occurs.
        (RtcallWithLoggert_doReadOrWritetTrue(R
RFRG((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt_ioEventCallback’scCss||krdS|}||krC|j|j|ƒ||O}n|j|||jƒ|j|<|j|ƒdS(s
        Add the given L{FileDescriptor} for monitoring either for reading or
        writing. If the file is already monitored for the other operation, we
        delete the previous registration and re-register it for both reading
        and writing.
        N(R2R.RNRRtadd(R
RFtprimarytothertprimaryFlagt	otherFlagtflags((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt_add›s
cCs)|j||j|j|j|jƒdS(sS
        Add a L{FileDescriptor} for monitoring of data available to read.
        N(RYR,R-tINFLAGStOUTFLAGS(R
treader((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt	addReader­scCs)|j||j|j|j|jƒdS(sO
        Add a L{FileDescriptor} for monitoring ability to write data.
        N(RYR-R,R[RZ(R
twriter((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt	addWriterµscCs
t|jƒS(sW
        Retrieve the list of current L{FileDescriptor} monitored for reading.
        (tlistR,(R
((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt
getReaders½scCs
t|jƒS(sW
        Retrieve the list of current L{FileDescriptor} monitored for writing.
        (R`R-(R
((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt
getWritersÄscCs|j|j|jƒS(sJ
        Remove monitoring for all registered L{FileDescriptor}s.
        (t
_removeAllR,R-(R
((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt	removeAllËscCss||krdS|j|j|ƒ|j|ƒ||kr_|j|||jƒ|j|<n|jj|ƒdS(sÝ
        Remove monitoring the given L{FileDescriptor} for either reading or
        writing. If it's still monitored for the other operation, we
        re-register the L{FileDescriptor} for only that operation.
        N(R2R.tremoveRNRRtpop(R
RFRTRURX((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt_removeÒs
cCs#|j||j|j|jƒdS(sJ
        Stop monitoring the given L{FileDescriptor} for reading.
        N(RgR,R-R[(R
R\((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pytremoveReaderãscCs#|j||j|j|jƒdS(sJ
        Stop monitoring the given L{FileDescriptor} for writing.
        N(RgR-R,RZ(R
R^((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pytremoveWriterêsicCs.|jƒx|jƒr)|jdƒq
WdS(sv
        One iteration of the event loop, for trial's use.

        This is not used for actual reactor runs.
        iN(trunUntilCurrentR6R8(R
tdelay((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pytiterateñs
cCstjj|ƒ|jƒdS(s$
        Crash the reactor.
        N(RR/tcrashR9(R
((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyRmüscCstjj|ƒ|jƒdS(s#
        Stop the reactor.
        N(RR/tstoptwakeUp(R
((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyRnscCs:|j|jƒ|jd|ƒ|jr6|jƒndS(s"
        Run the reactor.
        tinstallSignalHandlersN(tcallWhenRunningt_rescheduletstartRunningt_startedR;(R
Rp((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyRAs	cOs&tjj|||Ž}|jƒ|S(s,
        Schedule a C{DelayedCall}.
        (RR/t	callLaterRr(R
targstkwargstresult((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyRus
cCsl|jdk	r+|j|jƒd|_n|jƒ}|dk	rh|jt|dƒ|jƒ|_ndS(s;
        Schedule a glib timeout for C{_simulate}.
        ièN(R+RR2ttimeoutR4tintR (R
Ry((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyRr(scCs|jƒ|jƒdS(sX
        Run timers, and then reschedule glib timeout for next scheduled event.
        N(RjRr(R
((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyR 5s
(RRR!RRRt
_wakerFactoryRR0RNRRRYR]R_RaRbRdRgRhRiRlRmRnRQRARuRrR (((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyR";s,
'	
													
		
tPortableGlibReactorBasecBs8eZdZed„Zd„Zed„Zd„ZRS(sŠ
    Base class for GObject event loop reactors that works on Windows.

    Sockets aren't supported by GObject's input_add on Win32.
    cs°dˆ_|ˆ_|ˆ_tjjˆƒˆjjˆ_ˆjj	ˆ_
‡fd†}|ry|ˆ_ˆjjˆ_
n3ˆjjƒˆ_‡fd†ˆ_ˆjjˆ_
dS(Ncs#ˆjjƒrˆjjƒndS(N(R#R$R%((R
(s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyR&MscsˆjjˆjjƒS(N(R'R(R)R*((R
(s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyRVs(RR+R'R#Rt
SelectReactorR0R1R2R3R4R9R:R;R@R)RA(R
RBRCRDR&((R
s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyR0Ds				cCstjj|ƒ|jƒdS(N(RR}RmR9(R
((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyRmZscCs=|jd|ƒ|jd|jƒ|jr9|jƒndS(NRpi(RsR4tsimulateRtR;(R
Rp((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyRA_s	cCs||jdk	r"|j|jƒn|jƒt|jƒdƒ}|dkrVd}n|jt|dƒ|jƒ|_dS(s@
        Run simulation loops and reschedule callbacks.
        g{®Gáz„?ièN(	R+RR2RltminRyR4RzR~(R
Ry((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyR~fs
	(	RRR!RR0RmRQRAR~(((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyR|>s
	(R!Rttwisted.internetRRRttwisted.internet.interfacesRttwisted.pythonRRttwisted.python.compatRtzope.interfaceRtobjectRRRR/t_PollLikeMixinR"R}R|(((s>/usr/lib/python2.7/dist-packages/twisted/internet/_glibbase.pyt<module>sÿ