o gcM-@sddlZddlZddlZddlmZddlmZdZGdddeZGdd d eZ Gd d d eZ Gd d d eZ Gddde Z GdddejZGddde ZejdkrGdddejZGdddejZGdddejZGddde ZGddde ZGdd d e Zeeed!Zejd"kreed#Zn#eed$ZnGd%ddejZGd&dde Zd#eiZeed#Zd'd(ZeZd)d*Zd+d,Zd-d.ZdS)/N)process) reductionc@ eZdZdS) ProcessErrorN__name__ __module__ __qualname__rrrx/home/lily/lilypond-2.24.1/release/binaries/dependencies/install/Python-3.10.8/lib/python3.10/multiprocessing/context.pyrrc@r)BufferTooShortNrrrrr rr rc@r) TimeoutErrorNrrrrr rr rc@r)AuthenticationErrorNrrrrr rr rc@s\eZdZeZeZeZeZeej Z eej Z eej Z ddZ ddZ dCddZdd Zd d ZdDd dZdEddZdEddZddZdFddZdGddZdGddZddZ  dHd d!Zd"d#Zd$d%Zdd&d'd(Zdd&d)d*Zd+d,Zd-d.ZdDd/d0Z d1d2Z!d3d4Z"d5d6Z#dDd7d8Z$dId:d;Z%dIdd?Z(e(j)d@d?Z(dAdBZ*d S)J BaseContextcCst}|dur td|S)z(Returns the number of CPUs in the systemNzcannot determine number of cpus)os cpu_countNotImplementedError)selfZnumrrr r)szBaseContext.cpu_countcCs&ddlm}||d}||S)zReturns a manager associated with a running server process The managers methods such as `Lock()`, `Condition()` and `Queue()` can be used to create shared objects. r) SyncManagerctx)Zmanagersr get_contextstart)rrmrrr Manager1s zBaseContext.ManagerTcCddlm}||S)z1Returns two connection object connected by a piper)Pipe) connectionr)rduplexrrrr r< zBaseContext.PipecCddlm}||dS)z#Returns a non-recursive lock objectr)Lockr) synchronizer#r)rr#rrr r#A zBaseContext.LockcCr")zReturns a recursive lock objectr)RLockr)r$r&r)rr&rrr r&Fr%zBaseContext.RLockNcCddlm}|||dS)zReturns a condition objectr) Conditionr)r$r(r)rlockr(rrr r(K zBaseContext.ConditionrcCr')zReturns a semaphore objectr) Semaphorer)r$r+r)rvaluer+rrr r+Pr*zBaseContext.SemaphorecCr')z"Returns a bounded semaphore objectr)BoundedSemaphorer)r$r-r)rr,r-rrr r-Ur*zBaseContext.BoundedSemaphorecCr")zReturns an event objectr)Eventr)r$r.r)rr.rrr r.Zr%zBaseContext.EventcC ddlm}|||||dS)zReturns a barrier objectr)Barrierr)r$r0r)rpartiesactiontimeoutr0rrr r0_s zBaseContext.BarrierrcCr')Returns a queue objectr)Queuer)queuesr5r)rmaxsizer5rrr r5dr*zBaseContext.QueuecCr')r4r) JoinableQueuer)r6r8r)rr7r8rrr r8ir*zBaseContext.JoinableQueuecCr")r4r) SimpleQueuer)r6r9r)rr9rrr r9nr%zBaseContext.SimpleQueuercCs"ddlm}||||||dS)zReturns a process pool objectr)Pool)context)Zpoolr:r)r processes initializerinitargsZmaxtasksperchildr:rrr r:ss  zBaseContext.PoolcGsddlm}||g|RS)zReturns a shared objectr)RawValue) sharedctypesr?)rtypecode_or_typeargsr?rrr r?zr*zBaseContext.RawValuecCsddlm}|||S)zReturns a shared arrayr)RawArray)r@rC)rrAsize_or_initializerrCrrr rCs  zBaseContext.RawArray)r)cGs(ddlm}||g|R||dS)z$Returns a synchronized shared objectr)Valuer)r)r@rEr)rrAr)rBrErrr rEs zBaseContext.ValuecCr/)z#Returns a synchronized shared arrayr)ArrayrF)r@rGr)rrArDr)rGrrr rGs zBaseContext.ArraycCs4tjdkrttddrddlm}|dSdSdS)zCheck whether this is a fake forked process in a frozen executable. If so then run code specified by commandline and exit. win32frozenFr)freeze_supportN)sysplatformgetattrspawnrJ)rrJrrr rJs  zBaseContext.freeze_supportcCsddlm}|S)zZReturn package logger -- if it does not already exist then it is created. r) get_logger)utilrO)rrOrrr rOs zBaseContext.get_loggercCr)z8Turn on logging and add a handler which prints to stderrr) log_to_stderr)rPrQ)rlevelrQrrr rQr!zBaseContext.log_to_stderrcCsddlm}dS)zVInstall support for sending connections and sockets between processes r)rN)r)rrrrr allow_connection_picklingsz%BaseContext.allow_connection_picklingcCddlm}||dS)zSets the path to a python.exe or pythonw.exe binary used to run child processes instead of sys.executable when using the 'spawn' start method. Useful for people embedding Python. r)set_executableN)rNrV)r executablerVrrr rVs  zBaseContext.set_executablecCrU)zkSet list of module names to try to load in forkserver process. This is really just a hint. r)set_forkserver_preloadN) forkserverrX)rZ module_namesrXrrr rXs  z"BaseContext.set_forkserver_preloadcCsB|dur|Szt|}Wntytd|dw||S)Nzcannot find context for %r)_concrete_contextsKeyError ValueError_check_available)rmethodrrrr rs  zBaseContext.get_contextFcCs|jSN)_namer allow_nonerrr get_start_methodszBaseContext.get_start_methodcCstd)Nz+cannot set start method of concrete context)r\rr^forcerrr set_start_methodszBaseContext.set_start_methodcCs tdS)z_Controls how objects will be reduced to a form that can be shared with other processes.r)globalsgetrrrr reducers zBaseContext.reducercCs|td<dS)Nr)rg)rrrrr rjcCdSr_rrirrr r]szBaseContext._check_available)Tr_)r)NN)r)NNrNF)+r r r rrrr staticmethodrcurrent_processZparent_processZactive_childrenrrrr#r&r(r+r-r.r0r5r8r9r:r?rCrErGrJrOrQrTrVrXrrcrfpropertyrjsetterr]rrrr rsT                 rc@s(eZdZdZeddZeddZdS)ProcessNcCstj|Sr_)_default_contextrrr_Popen) process_objrrr rtszProcess._PopencCstjSr_)rsrrr _after_forkrrrr rvrkzProcess._after_forkr r r _start_methodrnrtrvrrrr rrs  rrcsFeZdZeZddZd fdd ZdddZdd d Zd d ZZ S)DefaultContextcCs||_d|_dSr_)rs_actual_context)rr;rrr __init__s zDefaultContext.__init__Ncs,|dur|jdur |j|_|jSt|Sr_)rzrssuperr)rr^ __class__rr rs   zDefaultContext.get_contextFcCs<|jdur |s td|dur|rd|_dS|||_dS)Nzcontext has already been set)rz RuntimeErrorrrdrrr rfs  zDefaultContext.set_start_methodcCs"|jdur |r dS|j|_|jjSr_)rzrsr`rarrr rcs zDefaultContext.get_start_methodcCs>tjdkrdgStjdkrddgnddg}tjr|d|S)NrHrNdarwinforkrY)rKrLrHAVE_SEND_HANDLEappend)rmethodsrrr get_all_start_methodss  z$DefaultContext.get_all_start_methodsr_rm) r r r rrr{rrfrcr __classcell__rrr}r rys  ryrHc@eZdZdZeddZdS) ForkProcessrcCddlm}||SNr)Popen)Z popen_forkrrurrrr rtr!zForkProcess._PopenNr r r rxrnrtrrrr rrc@(eZdZdZeddZeddZdS) SpawnProcessrNcCrr)Zpopen_spawn_posixrrrrr rtr!SpawnProcess._PopencCrlr_rrrrr rv"SpawnProcess._after_forkNrwrrrr r  rc@r)ForkServerProcessrYcCrr)Zpopen_forkserverrrrrr rt)r!zForkServerProcess._PopenNrrrrr r'rrc@eZdZdZeZdS) ForkContextrN)r r r r`rrrrrrr r.rc@r SpawnContextrNNr r r r`rrrrrrr r2rrc@seZdZdZeZddZdS)ForkServerContextrYcCstjstddS)Nz%forkserver start method not available)rrr\rirrr r]9sz"ForkServerContext._check_availableN)r r r r`rrrr]rrrr r6s r)rrNrYrrNrc@r)rrNcCrr)Zpopen_spawn_win32rrrrr rtMr!rcCrlr_rrrrr rvRrrNrwrrrr rKrc@rrrrrrr rWrcCst|t_dSr_)rZrsrz)r^rrr _force_start_methoddsrcCs ttddS)Nspawning_popen)rM_tlsrrrr get_spawning_popenms rcCs |t_dSr_)rr)popenrrr set_spawning_popenps rcCs tdurtdt|jdS)NzF%s objects should only be shared between processes through inheritance)rrtyper )objrrr assert_spawningss r) rrK threadingrSrr__all__ ExceptionrrrrobjectrZ BaseProcessrrryrLrrrrrrrZrsrlocalrrrrrrrr sL  ? ,