Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / eventlet / greenthread.pyc
Size: Mime:
ó
 ‹EYc@srddlmZddlZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZm
Z
ddlZd	d
ddd
dddgZejZdd„Zd„Zd„Zd„Zd„Zd„Zd„ZeZd„Zd„ddejfddejffDƒ\ZZd„Zdejfd „ƒYZd!„Zd"„Z dS(#iÿÿÿÿ(tdequeN(tevent(thubs(tsupport(ttimeout(ttimer(t	greenletstsixt
getcurrenttsleeptspawntspawn_ntkilltspawn_aftertspawn_after_localtGreenThreadicCsetjƒ}tƒ}|j|k	s0tdƒ‚|j||jƒ}z|jƒWd|jƒXdS(s	Yield control to another eligible coroutine until at least *seconds* have
    elapsed.

    *seconds* may be specified as an integer, or a float if fractional seconds
    are desired. Calling :func:`~greenthread.sleep` with *seconds* of 0 is the
    canonical way of expressing a cooperative yield. For example, if one is
    looping over a large list performing an expensive calculation without
    calling any socket methods, it's a good idea to call ``sleep(0)``
    occasionally; otherwise nothing else will run.
    s0do not call blocking functions from the mainloopN(Rtget_hubRtgreenlettAssertionErrortschedule_call_globaltswitchtcancel(tsecondsthubtcurrentR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyR	s	cOs;tjƒ}t|jƒ}|jd|j|||ƒ|S(s”Create a greenthread to run ``func(*args, **kwargs)``.  Returns a
    :class:`GreenThread` object which you can use to get the results of the
    call.

    Execution control returns immediately to the caller; the created greenthread
    is merely scheduled to be run at the next available opportunity.
    Use :func:`spawn_after` to  arrange for greenthreads to be spawned
    after a finite delay.
    i(RRRRRR(tfunctargstkwargsRtg((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyR
(s
cOstd|||ƒdS(s°Same as :func:`spawn`, but returns a ``greenlet`` object from
    which it is not possible to retrieve either a return value or
    whether it raised any exceptions.  This is faster than
    :func:`spawn`; it is fastest if there are no keyword arguments.

    If an exception is raised in the function, spawn_n prints a stack
    trace; the print can be disabled by calling
    :func:`eventlet.debug.hub_exceptions` with False.
    ii(t_spawn_n(RRR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyR8s
cOs;tjƒ}t|jƒ}|j||j|||ƒ|S(shSpawns *func* after *seconds* have elapsed.  It runs as scheduled even if
    the current greenthread has completed.

    *seconds* may be specified as an integer, or a float if fractional seconds
    are desired. The *func* will be called with the given *args* and
    keyword arguments *kwargs*, and will be executed within its own greenthread.

    The return value of :func:`spawn_after` is a :class:`GreenThread` object,
    which can be used to retrieve the results of the call.

    To cancel the spawn and prevent *func* from being called,
    call :meth:`GreenThread.cancel` on the return value of :func:`spawn_after`.
    This will not abort the function if it's already started running, which is
    generally the desired behavior.  If terminating *func* regardless of whether
    it's started or not is the desired behavior, call :meth:`GreenThread.kill`.
    (RRRRRR(RRRRRR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyR
EscOs;tjƒ}t|jƒ}|j||j|||ƒ|S(s+Spawns *func* after *seconds* have elapsed.  The function will NOT be
    called if the current greenthread has exited.

    *seconds* may be specified as an integer, or a float if fractional seconds
    are desired. The *func* will be called with the given *args* and
    keyword arguments *kwargs*, and will be executed within its own greenthread.

    The return value of :func:`spawn_after` is a :class:`GreenThread` object,
    which can be used to retrieve the results of the call.

    To cancel the spawn and prevent *func* from being called,
    call :meth:`GreenThread.cancel` on the return value. This will not abort the
    function if it's already started running.  If terminating *func* regardless
    of whether it's started or not is the desired behavior, call
    :meth:`GreenThread.kill`.
    (RRRRtschedule_call_localR(RRRRRR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyR\scOs-tjdtddƒt||||ƒdS(Nsªcall_after_global is renamed to spawn_after, whichhas the same signature and semantics (plus a bit extra).  Please do a quick search-and-replace on your codebase, thanks!t
stacklevelii(twarningstwarntDeprecationWarningR(RRRR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pytcall_after_globalss
cOsYtjdtddƒtjƒ}tj|d|jƒ}|j||j||Ž}|S(Nsocall_after_local is renamed to spawn_after_local, whichhas the same signature and semantics (plus a bit extra).Ritparent(R R!R"RRRRR(RtfunctionRRRRtt((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pytcall_after_local|s
cGsZtjdtddƒ|dkr5tj|d„ƒStjƒ}|j|t	ƒj
|ŒS(NsJInstead of exc_after, which is deprecated, use Timeout(seconds, exception)RicSsdS(N(tNone(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyt<lambda>s(R R!R"R(RtTimerRRRRtthrow(Rt
throw_argsR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyt	exc_afterŠs	
ccs0|]&\}}}tj||ƒ|ƒVqdS(N(Rtwrap_deprecated(t.0toldtnewtfun((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pys	<genexpr>•ssgreenthread.TimeoutErrortTimeoutsgreenthread.with_timeouttwith_timeoutcCsItjƒ}tj|d|jƒ}|j||j||Ž}||fS(NR$(RRRRR(RRRRRRR&((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyR›scBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
RS(	séThe GreenThread class is a type of Greenlet which has the additional
    property of being able to retrieve the return value of the main function.
    Do not construct GreenThread objects directly; call :func:`spawn` to get one.
    cCs5tjj||j|ƒtjƒ|_t|_dS(N(Rt__init__tmainRtEventt_exit_eventtFalset_resolving_links(tselfR$((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyR5¨scCs
|jjƒS(sH Returns the result of the main function of this GreenThread.  If the
        result is a normal return value, :meth:`wait` returns it.  If it raised
        an exception, :meth:`wait` will raise the same exception (though the
        stack trace will unavoidably contain some frames from within the
        greenthread module).(R8twait(R;((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyR<­scOsQt|dtƒƒ|_|jj|||fƒ|jjƒrM|jƒndS(sÓ Set up a function to be called with the results of the GreenThread.

        The function must have the following signature::

            def func(gt, [curried args/kwargs]):

        When the GreenThread finishes its run, it calls *func* with itself
        and with the `curried arguments <http://en.wikipedia.org/wiki/Currying>`_ supplied
        at link-time.  If the function wants to retrieve the result of the GreenThread,
        it should call wait() on its first argument.

        Note that *func* is called within execution context of
        the GreenThread, so it is possible to interfere with other linked
        functions by doing things like switching explicitly to another
        greenthread.
        t_exit_funcsN(tgetattrRR=tappendR8treadyt_resolve_links(R;Rtcurried_argstcurried_kwargs((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pytlinkµscOsPt|ddƒstSy!|jj|||fƒtSWntk
rKtSXdS(sn remove linked function set by :meth:`link`

        Remove successfully return True, otherwise False
        R=N(R>R(R9R=tremovetTruet
ValueError(R;RRBRC((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pytunlinkËs
cCs^y|||Ž}Wn*|jjtjƒŒ|jƒ‚nX|jj|ƒ|jƒdS(N(R8tsend_exceptiontsystexc_infoRAtsend(R;R%RRtresult((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyR6Øs
cCsr|jr
dSt|_zKt|dtƒƒ}x/|r_|jƒ\}}}||||Žq1WWdt|_XdS(NR=(R:RFR>RtpopleftR9(R;t
exit_funcstftcatckw((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyRAãs			cGs
t||ŒS(s²Kills the greenthread using :func:`kill`.  After being killed
        all calls to :meth:`wait` will raise *throw_args* (which default
        to :class:`greenlet.GreenletExit`).(R(R;R,((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyRðscGs
t||ŒS(sìKills the greenthread using :func:`kill`, but only if it hasn't
        already started running.  After being canceled,
        all calls to :meth:`wait` will raise *throw_args* (which default
        to :class:`greenlet.GreenletExit`).(R(R;R,((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyRös(t__name__t
__module__t__doc__R5R<RDRHR6RARR(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyR¢s				
		
	cGs|st||ŒndS(s¶Like :func:`kill`, but only terminates the greenthread if it hasn't
    already started execution.  If the grenthread has already started
    execution, :func:`cancel` has no effect.N(R(RR,((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyRþscs¶|jr
dStjƒ}|sm‡fd†}||_t|tƒrmy|j|diƒWqjqjXqmntƒ}||jk	r¥|j	ƒ|j
d|jƒn|jˆŒdS(sêTerminates the target greenthread by raising an exception into it.
    Whatever that greenthread might be doing; be it waiting for I/O or another
    primitive, it sees an exception right away.

    By default, this exception is GreenletExit, but a specific exception
    may be specified.  *throw_args* should be the same as the arguments to
    raise; either an exception instance or an exc_info tuple.

    Calling :func:`kill` causes the calling greenthread to cooperatively yield.
    Ncs8ˆr(tjˆdˆdˆdƒntjƒ‚dS(Niii(RtreraiseRtGreenletExit(tatkw(R,(sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyt
just_raises"i((
tdeadRRtrunt
isinstanceRR6RRtensure_greenletRRR+(RR,RRZR((R,sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyRs 		
	
(!tcollectionsRRJteventletRRRRt
eventlet.hubsRteventlet.supportRRRR t__all__RR	R
RR
RR#R't
call_afterR-R3R4tTimeoutErrorRRRR(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenthread.pyt<module>s8			
							\