o cc@Y @sdZddlZddlZddlZddlZddlZdZdZdZdZ dZ dZ d Z d Z d Ze e e e egZe d e d e de dediZedZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdd d eZGd!d"d"eZd#d$Zd%d&Zd5d'd(Z e!d)d*Z"defd+d,Z#d5d-d.Z$Gd/d0d0eZ%Gd1d2d2eZ&Gd3d4d4e'Z(dS)6z"Brian Quinlan (brian@sweetapp.com)NFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETED _AS_COMPLETEDPENDINGRUNNING CANCELLEDCANCELLED_AND_NOTIFIEDFINISHEDpendingrunning cancelledfinishedzconcurrent.futuresc@eZdZ dS)ErrorN__name__ __module__ __qualname__rry/home/lily/lilypond-2.24.1/release/binaries/dependencies/install/Python-3.10.8/lib/python3.10/concurrent/futures/_base.pyr-rc@r)CancelledErrorNrrrrrr1rrc@r) TimeoutErrorNrrrrrr5rrc@r)InvalidStateErrorNrrrrrr9rrc@s.eZdZ ddZddZddZddZd S) _WaitercCst|_g|_dSN) threadingZEventeventfinished_futuresselfrrr__init__?s  z_Waiter.__init__cC|j|dSrrappendr!futurerrr add_resultCz_Waiter.add_resultcCr#rr$r&rrr add_exceptionFr)z_Waiter.add_exceptioncCr#rr$r&rrr add_cancelledIr)z_Waiter.add_cancelledN)rrrr"r(r*r+rrrrr=s  rcsBeZdZ fddZfddZfddZfddZZS) _AsCompletedWaitercstt|t|_dSr)superr,r"rLocklockr  __class__rrr"Osz_AsCompletedWaiter.__init__cF|jtt|||jWddS1swYdSr)r/r-r,r(rsetr&r0rrr(S "z_AsCompletedWaiter.add_resultcr2r)r/r-r,r*rr3r&r0rrr*Xr4z _AsCompletedWaiter.add_exceptioncr2r)r/r-r,r+rr3r&r0rrr+]r4z _AsCompletedWaiter.add_cancelled)rrrr"r(r*r+ __classcell__rrr0rr,Ls    r,cs6eZdZ fddZfddZfddZZS)_FirstCompletedWaiterct||jdSr)r-r(rr3r&r0rrr(e z _FirstCompletedWaiter.add_resultcr7r)r-r*rr3r&r0rrr*ir8z#_FirstCompletedWaiter.add_exceptioncr7r)r-r+rr3r&r0rrr+mr8z#_FirstCompletedWaiter.add_cancelled)rrrr(r*r+r5rrr0rr6bs   r6csJeZdZ fddZddZfddZfddZfd d ZZS) _AllCompletedWaitercs$||_||_t|_tdSr)num_pending_callsstop_on_exceptionrr.r/r-r")r!r:r;r0rrr"ts z_AllCompletedWaiter.__init__cCsZ|j |jd8_|js|jWddSWddS1s&wYdS)N)r/r:rr3r rrr_decrement_pending_callszs "z,_AllCompletedWaiter._decrement_pending_callsct||dSr)r-r(r=r&r0rrr(  z_AllCompletedWaiter.add_resultcs,t||jr|jdS|dSr)r-r*r;rr3r=r&r0rrr*s  z!_AllCompletedWaiter.add_exceptioncr>r)r-r+r=r&r0rrr+r?z!_AllCompletedWaiter.add_cancelled) rrrr"r=r(r*r+r5rrr0rr9qs   r9c@s&eZdZ ddZddZddZdS)_AcquireFuturescCst|td|_dS)N)key)sortedidfutures)r!rDrrrr"sz_AcquireFutures.__init__cCs|jD]}|jqdSr)rD _conditionacquirer&rrr __enter__  z_AcquireFutures.__enter__cGs|jD]}|jqdSr)rDrErelease)r!argsr'rrr__exit__rHz_AcquireFutures.__exit__N)rrrr"rGrKrrrrr@s  r@cCs|tkrt}n-|tkrt}n%tdd|D}|tkr$t|dd}n|tkr/t|dd}ntd||D]}|j |q7|S)Ncss|] }|jttfvVqdSr_stater r .0frrr s z._create_and_install_waiters..T)r;FzInvalid return condition: %r) rr,rr6sumrr9r ValueError_waitersr%)fs return_whenwaiterZ pending_countrPrrr_create_and_install_waiterss rXccsn |r5|d}|D]}||q |j|j|Wdn1s&wY~|V|sdSdS)N)removerErTpop)rUrW ref_collectrPZ futures_setrrr_yield_finished_futuress    r]c cs |dur |t}t|}t|}t|tdd|D}||}t|t}Wdn1s5wYt|}zt|||fdEdH|r|durSd}n|t}|dkrgt dt||f|j ||j |j }g|_ |j Wdn1swY|t||||fdEdH|sLW|D]}|j|j|Wdn1swYqdS|D]}|j|j|Wdn1swYqw)Ncss"|] }|jttfvr|VqdSrrLrNrrrrQszas_completed..)r\rz%d (of %d) futures unfinished)time monotonicr3lenr@rXrlistr]rrwaitr/rclearreverserErTrZ) rUtimeoutend_timeZ total_futuresrr rWZ wait_timeoutrPrrr as_completedsf         rgDoneAndNotDoneFuturesz done not_donec Cs6 t|}t|Ydd|D}||}|tkr'|r't||WdS|tkrB|rBtdd|DrBt||WdSt|t|krVt||WdSt||}Wdn1sewY|j ||D]}|j |j |Wdn1swYqr| |jt|||S)NcSsh|] }|jttfvr|qSrrLrNrrr $szwait..css(|]}|s|dur|VqdSr)r exceptionrNrrrrQ*s zwait..)r3r@rrhranyr`rXrrbrErTrZupdater)rUrerVdoneZnot_donerWrPrrrrb s2       rbcCs*zz ||W|W~S|w~wr)resultcancel)Zfutrerrr_result_or_cancel<s   rpc@seZdZ ddZddZddZddZd d Zd d Zd dZ ddZ ddZ dddZ dddZ ddZddZddZeejZdS)FuturecCs. t|_t|_d|_d|_g|_g|_dSr) rZ ConditionrErrM_result _exceptionrT_done_callbacksr rrrr"Js  zFuture.__init__c Cs:|jD]}z||Wqtytd|YqwdSNz!exception calling callback for %r)rt ExceptionLOGGERrj)r!callbackrrr_invoke_callbacksSs   zFuture._invoke_callbackscCs|jP|jtkr>|jr%d|jjt|t|j|jjjfWdSd|jjt|t|j|jjjfWdSd|jjt|t|jfWdS1sVwYdS)Nz<%s at %#x state=%s raised %s>z <%s at %#x state=%s returned %s>z<%s at %#x state=%s>) rErMr rsr1rrC_STATE_TO_DESCRIPTION_MAPrrr rrr__repr__Zs.  $zFuture.__repr__cCs |j0|jttfvr WddS|jttfvr% WddSt|_|jWdn1s7wY|dS)NFT)rErMrr rr notify_allryr rrrrons  z Future.cancelcCs: |j|jttfvWdS1swYdSr)rErMrr r rrrr s $zFuture.cancelledcCs6 |j |jtkWdS1swYdSr)rErMrr rrrr s$zFuture.runningcCs< |j|jtttfvWdS1swYdSr)rErMrr r r rrrrms$z Future.donecCs|jr z|jd}w|jSr)rsrrr rrrZ __get_results zFuture.__get_resultcCs |j|jtttfvr|j| WddSWdn1s&wYz||WdStyBt d|YdSwru) rErMrr r rtr%rvrwrj)r!fnrrradd_done_callbacks   zFuture.add_done_callbackNcCs zT|jD|jttfvrt|jtkr#|WdWd}S|j||jttfvr3t|jtkrF|WdWd}St1sLwYWd}dSd}wr) rErMrr rr _Future__get_resultrbrr!rerrrrns&   z Future.resultcCs |j<|jttfvrt|jtkr|jWdS|j||jttfvr.t|jtkr=|jWdSt1sCwYdSr) rErMrr rr rsrbrrrrrrjs    zFuture.exceptioncCs |j<|jtkr!t|_|jD]}||q WddS|jtkr2t|_ WddSt dt ||jt d1sCwYdS)NFTz!Future %s in unexpected state: %szFuture in unexpected state) rErMrr rTr+rrrwZcriticalrC RuntimeError)r!rWrrrset_running_or_notify_cancels$     z#Future.set_running_or_notify_cancelcC |j/|jttthvrtd|j|||_t|_|jD]}| |q|j Wdn1s6wY| dSNz{}: {!r}) rErMrr r rformatrrrTr(r|ry)r!rnrWrrr set_result    zFuture.set_resultcCrr) rErMrr r rrrsrTr*r|ry)r!rjrWrrr set_exception*rzFuture.set_exceptionr)rrrr"ryr{ror r rmrr~rnrjrrr classmethodtypes GenericAlias__class_getitem__rrrrrqGs"   #"(rqc@sFeZdZ ddZdddddZdd d d d Zd dZddZdS)ExecutorcOs tr)NotImplementedError)r!r}rJkwargsrrrsubmit>szExecutor.submitNr<)re chunksizecsD dur tfddt|Dfdd}|S)Ncsg|] }jg|RqSr)r)rOrJ)r}r!rr bsz Executor.map..c 3spz,r"durtVn ttVsWD]}|q%dSD]}|q0wr)rdrpr[r^r_ro)r')rfrUrerrresult_iteratorfs  z%Executor.map..result_iterator)r^r_zip)r!r}rerZ iterablesrr)rfr}rUr!rermapIs   z Executor.mapTF)cancel_futurescCs dSrr)r!rbrrrrshutdownus zExecutor.shutdowncCs|Srrr rrrrGszExecutor.__enter__cCs|jdddS)NT)rbF)r)r!exc_typeZexc_valZexc_tbrrrrKs zExecutor.__exit__)T)rrrrrrrGrKrrrrr;s , rc@s eZdZdS)BrokenExecutorNrrrrrrsrr)) __author__ collectionsZloggingrr^rrrrrrrrr r Z_FUTURE_STATESrzZ getLoggerrwrvrrrrobjectrr,r6r9r@rXr]rg namedtuplerhrbrprqrrrrrrrsb   > 3 uR