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 / greenpool.pyc
Size: Mime:
ó
 ‹EYc@s©ddlZddlZddlmZddlmZddlmZddgZeZ	de
fd„ƒYZd„Zde
fd	„ƒYZ
d
e
fd„ƒYZdS(iÿÿÿÿN(tqueue(t	greenlets(tsixt	GreenPoolt	GreenPilecBs†eZdZdd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d	„Z
d
„Zd„Zd„Z
d
„Zd„ZRS(s4The GreenPool class is a pool of green threads.
    iècCsºyt|ƒ}Wn=tk
rO}djt|ƒt|ƒƒ}t|ƒ‚nX|dkr€djt|ƒƒ}t|ƒ‚n||_tƒ|_	t
j|ƒ|_t
j
ƒ|_dS(Ns/GreenPool() expect size :: int, actual: {0} {1}is)GreenPool() expect size >= 0, actual: {0}(tintt
ValueErrortformatttypetstrt	TypeErrortreprtsizetsettcoroutines_runningteventlett	SemaphoretsemtEventtno_coros_running(tselfRtetmsg((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyt__init__s	cCs,||j}|jj|7_||_dS(s½ Change the max number of greenthreads doing work at any given time.

        If resize is called when there are more than *new_size* greenthreads
        already working on tasks, they will be allowed to complete but no new
        tasks will be allowed to get launched until enough greenthreads finish
        their tasks to drop the overall quantity below *new_size*.  Until
        then, the return value of free() will be negative.
        N(RRtcounter(Rtnew_sizet
size_delta((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pytresizes	
cCs
t|jƒS(sd Returns the number of greenthreads that are currently executing
        functions in the GreenPool.(tlenR(R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pytrunning,scCs
|jjS(sÍ Returns the number of greenthreads available for use.

        If zero or less, the next call to :meth:`spawn` or :meth:`spawn_n` will
        block the calling greenthread until a slot becomes available.(RR(R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pytfree1scOs´tjƒ}|jjƒrS||jkrStjj|ƒ}|j|||ƒ|S|jjƒtj	|||Ž}|jstj
ƒ|_n|jj|ƒ|j
|jƒ|S(s
Run the *function* with its arguments in its own green thread.
        Returns the :class:`GreenThread <eventlet.GreenThread>`
        object that is running the function, which can be used to retrieve the
        results.

        If the pool is currently at capacity, ``spawn`` will block until one of
        the running greenthreads completes its task and frees up a slot.

        This function is reentrant; *function* can call ``spawn`` on the same
        pool without risk of deadlocking the whole thing.
        (Rt
getcurrentRtlockedRtgreenthreadtGreenThreadtmaintacquiretspawnRRtaddtlinkt_spawn_done(Rtfunctiontargstkwargstcurrenttgt((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyR%8s
	cCs‚zQy|||ŽWn9tttjfk
r6‚ntrPtjƒqPnXWd|dkrddStj	ƒ}|j
|ƒXdS(N(tKeyboardInterruptt
SystemExittgreenlettGreenletExittDEBUGt	tracebackt	print_exctNoneRRR((RtfuncR*R+tcoro((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyt
_spawn_n_implUscOstjƒ}|jjƒrC||jkrC|j|||dƒnV|jjƒtj|j|||t	ƒ}|js‰tj
ƒ|_n|jj|ƒdS(sÄCreate a greenthread to run the *function*, the same as
        :meth:`spawn`.  The difference is that :meth:`spawn_n` returns
        None; the results of *function* are not retrievable.
        N(
RRRR RR8R5R$tspawn_ntTrueRRR&(RR)R*R+R,tg((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyR9es
	cCsAtjƒ|jks!tdƒ‚|jƒr=|jjƒndS(s>Waits until all greenthreads in the pool are finished working.sWCalling waitall() from within one of the GreenPool's greenthreads will never terminate.N(RRRtAssertionErrorRRtwait(R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pytwaitallxs	cCsX|jjƒ|dk	r,|jj|ƒn|jj|jkrT|jjdƒndS(N(	RtreleaseR5RtremovetbalanceRRtsend(RR7((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyR(€s

cCs%|jjdkr|jjSdSdS(s<Return the number of greenthreads waiting to spawn.
        iN(RRA(R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pytwaiting‰scCs2x|D]}|j||ŒqW|jtƒdS(N(R%treturn_stop_iteration(RR6tittgiR*((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyt_do_map‘s
cCsD|dkrd„}nt|jƒ}tj|j|||ƒ|S(suThis is the same as :func:`itertools.starmap`, except that *func* is
        executed in a separate green thread for each item, with the concurrency
        limited by the pool's size. In operation, starmap consumes a constant
        amount of memory, proportional to the size of the pool, and is thus
        suited for iterating over extremely long input lists.
        cWs|S(N((ta((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyt<lambda>žsN(R5tGreenMapRRR9RG(RR)titerableRF((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pytstarmap–s
cGs|j|tjj|ŒƒS(sThis is the same as :func:`itertools.imap`, and has the same
        concurrency and memory behavior as :meth:`starmap`.

        It's quite convenient for, e.g., farming out jobs from a file::

           def worker(line):
               return do_something(line)
           pool = GreenPool()
           for result in pool.imap(worker, open("filename", 'r')):
               print(result)
        (RLRtmovestzip(RR)t	iterables((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pytimap£s(t__name__t
__module__t__doc__RRRRR%R8R9R>R(RCRGRLRP(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyR
s	
											
cCstƒS(N(t
StopIteration(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyRD²scBs;eZdZdd„Zd„Zd„Zd„ZeZRS(sGreenPile is an abstraction representing a bunch of I/O-related tasks.

    Construct a GreenPile with an existing GreenPool object.  The GreenPile will
    then use that pool's concurrency as it processes its jobs.  There can be
    many GreenPiles associated with a single GreenPool.

    A GreenPile can also be constructed standalone, not associated with any
    GreenPool.  To do this, construct it with an integer size parameter instead
    of a GreenPool.

    It is not advisable to iterate over a GreenPile in a different greenthread
    than the one which is calling spawn.  The iterator will exit early in that
    situation.
    iècCsOt|tƒr||_nt|ƒ|_tjƒ|_t|_d|_dS(Ni(	t
isinstanceRtpoolRt
LightQueuetwaiterstFalsetusedR(Rtsize_or_pool((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyRÆs	cOsdt|_|jd7_y,|jj|||Ž}|jj|ƒWn|jd8_‚nXdS(snRuns *func* in its own green thread, with the result available by
        iterating over the GreenPile object.iN(R:RZRRVR%RXtput(RR6R*tkwR-((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyR%Ïs	cCs|S(N((R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyt__iter__ÛscCsR|jdkr$|jr$tƒ‚nz|jjƒjƒSWd|jd8_XdS(s‘Wait for the next result, suspending the current greenthread until it
        is available.  Raises StopIteration when there are no more results.iNi(RRZRTRXtgetR=(R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pytnextÞs
(RQRRRSRR%R^R`t__next__(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyR¶s					RJcBs eZd„Zd„ZeZRS(cCs5tt|ƒj|ƒtjd|jjƒ|_dS(Ntmaxsize(tsuperRJRRRWRVRRX(RR[((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyRîscCsLz5|jjƒjƒ}t|tƒr0|‚n|SWd|jd8_XdS(Ni(RXR_R=RURTR(Rtval((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyR`òs	(RQRRRR`Ra(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyRJís			(R3RRteventlet.supportRR0Rt__all__R:R2tobjectRRDRRJ(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/greenpool.pyt<module>s¥	7