Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/mercurial/worker.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��c@s�ddlmZddlZddlZddlZddlZddlZddlZd�Zd�Z	ej
dkr�dZndZd�Zd	�Z
d
�Zd�Zej
dkr�eZeZnd
�ZdS(i�(t_NcCs�y)ttjd��}|dkr(|SWnttfk
rBnXy'ttjd�}|dkri|SWnttfk
r�nXdS(s-try to count the number of CPUs on the systemtSC_NPROCESSORS_ONLNitNUMBER_OF_PROCESSORSi(tinttostsysconftAttributeErrort
ValueErrortenvirontKeyError(tn((s4/sys/lib/python2.7/site-packages/mercurial/worker.pyt	countcpusscCs}|jdd�}|rdy t|�}|dkr7|SWqdtk
r`tjtd���qdXnttt�d�d�S(Ntworkertnumcpusis!number of cpus must be an integerii (	tconfigRRtutiltAbortRtmintmaxR(tuitsR
((s4/sys/lib/python2.7/site-packages/mercurial/worker.pyt_numworkers s
tposixgz��?g錠9Y>)FcCs6||}t|�}|t|||}|dkS(setry to determine whether the benefit of multiple processes can
    outweigh the cost of starting themg333333�(Rt_startupcost(Rt	costperoptnopstlineartworkerstbenefit((s4/sys/lib/python2.7/site-packages/mercurial/worker.pyt
worthwhile0s
cCs<t||t|��r+t||||�S|||f�S(sFrun a function, possibly in parallel in multiple worker
    processes.

    returns a progress iterator

    costperarg - cost of a single task

    func - function to run

    staticargs - arguments to pass to every invocation of the function

    args - arguments to split into chunks, to pass to individual
    workers
    (Rtlent_platformworker(Rt
costperargtfunct
staticargstargs((s4/sys/lib/python2.7/site-packages/mercurial/worker.pyR8sc#s8tj�\}}t|�}tjtj��tjtjtj�gdg��x�||�D]�tj�}|dkr<tjtj��y\tj	|�x;|||f�D]&\}	}
tj
|d|	|
f�q�Wtjd�Wq<tk
rtjd�q<z|j
�Wdtjd�Xq<Xn�j|�qfW�j�tj	|�tj|dd�}�fd�����fd�}tjd|���j����fd�}
yDx=|D]5}|jd	d
�}t|d�|d
d fVq�WWn��|
��nX|
�dS(Nis%d %s
i�trbcsZxS�D]K}ytj|tj�Wqtk
rQ}|jtjkrR�qRqXqWdS(N(RtkilltsignaltSIGTERMtOSErrorterrnotESRCH(tpterr(tpids(s4/sys/lib/python2.7/site-packages/mercurial/worker.pytkillworkerses
csLxE�D]=}ttj�d�}|r�r|�d<��qqWdS(Nii(t_exitstatusRtwait(Rtst(R.R-tproblem(s4/sys/lib/python2.7/site-packages/mercurial/worker.pytwaitforworkersms



ttargetcsgtjtj���j��d}|rc|dkrStjtj�|�ntj|�ndS(Ni(R&tSIGINTtjoinRR%tgetpidtsystexit(tstatus(t
oldhandlerR2tt(s4/sys/lib/python2.7/site-packages/mercurial/worker.pytcleanupus

t ii�(RtpipeRR&t	getsignalR5tSIG_IGNt	partitiontforktclosetwritet_exittKeyboardInterruptt	tracebacktappendtreversetfdopent	threadingtThreadtstarttsplitR(RR!R"R#trfdtwfdRtpargstpidtititemtfpR3R=tlinetl((R.R;R-R2R<s4/sys/lib/python2.7/site-packages/mercurial/worker.pyt_posixworkerKsL
 




%cCs=tj|�rtj|�Stj|�r9tj|�SdS(s�convert a posix exit status into the same form returned by
    os.spawnv

    returns None if the process was stopped instead of exitingN(Rt	WIFEXITEDtWEXITSTATUStWIFSIGNALEDtWTERMSIG(tcode((s4/sys/lib/python2.7/site-packages/mercurial/worker.pyt_posixexitstatus�s
tntccs{t|�}||||}}d}xMt|�D]?}|}||}|rg|d7}|d8}n|||!Vq4WdS(s,partition a list into N slices of equal sizeiiN(Rtxrange(tlsttnslicesR
tchunktsloptendRTRN((s4/sys/lib/python2.7/site-packages/mercurial/worker.pyRB�s


(ti18nRR)RR&R8RLRRRtnameRRRRYR_RR/RB(((s4/sys/lib/python2.7/site-packages/mercurial/worker.pyt<module>sH						<	
	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.