403Webshell
Server IP : 61.19.30.66  /  Your IP : 216.73.216.15
Web Server : Apache/2.2.22 (Ubuntu)
System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64
User : www-data ( 33)
PHP Version : 5.3.10-1ubuntu3.48
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python2.7/dist-packages/twisted/internet/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyc
ó
±ZOc@s”dZeZddlmZddlZddlZddlmZddl	m
Z
ddlmZde
fd„ƒYZ
eƒje
jƒƒdS(	s2
Tests for implementations of L{IReactorThreads}.
iÿÿÿÿ(trefN(tisInIOThread(tReactorBuilder(t
ThreadPooltThreadTestsBuildercBs_eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„ZRS(
sD
    Builder for defining tests relating to L{IReactorThreads}.
    cs²g‰|jƒ‰ˆjƒ‰|jˆtƒ|jˆjdƒ‡‡‡fd†}ˆj|ƒ|jˆdƒ|jˆddƒ|jˆddƒ|jˆj	dƒd	S(
s£
        C{reactor.getThreadPool()} returns an instance of L{ThreadPool} which
        starts when C{reactor.run()} is called and stops before it returns.
        s(Pool should not start before reactor.runcs.ˆjˆjƒˆjˆjƒˆjƒdS(N(tappendtstartedtjoinedtstop((tstatetreactortpool(sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pytf#siis#Pool should start after reactor.runis-Pool should not be joined before reactor.stops0Pool should be stopped after reactor.run returnsN(
tbuildReactort
getThreadPooltassertIsInstanceRtassertFalseRtcallWhenRunningt
runReactort
assertTrueR(tselfR((R
R	RsF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyttest_getThreadPools 

cCs<|jƒ}|jdƒ|jƒ}|j|jdƒdS(sm
        C{reactor.suggestThreadPoolSize()} sets the maximum size of the reactor
        threadpool.
        iN(R
tsuggestThreadPoolSizeRtassertEqualtmax(RR
R((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyttest_suggestThreadPoolSize5s
cst|jƒ‰‡fd†}ˆjdˆj|ƒˆjƒ}|jˆdƒˆjƒ}|j||dkƒdS(sQ
        A function scheduled with L{IReactorThreads.callFromThread} invoked
        from a delayed call is run immediately in the next reactor iteration.

        When invoked from the reactor thread, previous implementations of
        L{IReactorThreads.callFromThread} would skip the pipe/socket based wake
        up step, assuming the reactor would wake up on its own.  However, this
        resulted in the reactor not noticing a insert into the thread queue at
        the right time (in this case, after the thread queue has been processed
        for that reactor iteration).
        csˆjƒdS(N(R((R
(sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyt
threadCallNsii<iN(R
t	callLatertcallFromThreadtsecondsRR(RRtbeforetafter((R
sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyttest_delayedCallFromThread@scsm|jƒ‰g‰‡‡fd†}ˆjdˆjˆj|ƒ|jˆdƒ|jˆtjƒgƒdS(s
        A function scheduled with L{IReactorThreads.callFromThread} invoked
        from another thread is run in the reactor thread.
        cs!ˆjtjƒƒˆjƒdS(N(Rt	threadingt
currentThreadR((tresultR
(sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyRssiiN(R
RtcallInThreadRRtassertEqualsR!R"(RR((R
R#sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyttest_callFromThreadks
cCs\|jƒ}t|jƒƒ}|j|jƒ|j|ƒtjƒ|j|ƒdƒdS(s0
        When the reactor stops, L{ReactorBase._stopThreadPool} drops the
        reactor's direct reference to its internal threadpool and removes
        the associated startup and shutdown triggers.

        This is the case of the thread pool being created before the reactor
        is run.
        N(
R
RRRRRtgctcollecttassertIdenticaltNone(RR
t
threadpool((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyttest_stopThreadPool}s	

csc|jƒ‰g‰‡‡fd†}ˆj|ƒ|jˆƒtjƒ|jˆdƒdƒdS(s¶
        We must handle the case of shutting down the thread pool when it was
        started after the reactor was run in a special way.

        Some implementation background: The thread pool is started with
        callWhenRunning, which only returns a system trigger ID when it is
        invoked before the reactor is started.

        This is the case of the thread pool being created after the reactor
        is started.
        cs'ˆjtˆjƒƒƒˆjƒdS(N(RRRR((tthreadPoolRefsR
(sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pytacquireThreadPoolœsiN(R
RRR'R(R)R*(RR.((R
R-sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyt-test_stopThreadPoolWhenStartedAfterReactorRanŽs


cCsL|jƒ}t|jƒƒ}|jdƒtjƒ|j|ƒdƒdS(s[
        When the reactor has its shutdown event fired before it is run, the
        thread pool is completely destroyed.

        For what it's worth, the reason we support this behavior at all is
        because Trial does this.

        This is the case of the thread pool being created without the reactor
        being started at al.
        tshutdownN(R
RRtfireSystemEventR'R(R)R*(RR
t
threadPoolRef((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyt,test_cleanUpThreadPoolEvenBeforeReactorIsRun¥s


csUg‰|jƒ‰‡‡fd†}ˆj|ƒ|jˆƒ|jtgˆƒdS(sØ
        The reactor registers itself as the I/O thread when it runs so that
        L{twisted.python.threadable.isInIOThread} returns C{True} if it is
        called in the thread the reactor is running in.
        csˆjtƒƒˆjƒdS(N(RRR((tresultsR
(sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pytcheck¿sN(R
RRRtTrue(RR5((R4R
sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyttest_isInIOThread·s

csUg‰|jƒ‰‡‡fd†}ˆj|ƒ|jˆƒ|jtgˆƒdS(sæ
        The reactor registers itself as the I/O thread when it runs so that
        L{twisted.python.threadable.isInIOThread} returns C{False} if it is
        called in a different thread than the reactor is running in.
        cs$ˆjtƒƒˆjˆjƒdS(N(RRRR((R4R
(sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyR5ÏsN(R
R$RRtFalse(RR5((R4R
sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyttest_isNotInIOThreadÇs

(t__name__t
__module__t__doc__RRR R&R,R/R3R7R9(((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyRs			+					(R<ttypet
__metaclass__tweakrefRR'R!ttwisted.python.threadableRt#twisted.internet.test.reactormixinsRttwisted.python.threadpoolRRtglobalstupdatetmakeTestCaseClasses(((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_threads.pyt<module>sÅ

Youez - 2016 - github.com/yon3zu
LinuXploit