o ?OgM-@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__rrr>/opt/alt/python310/lib64/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 BaseContextcCs t}|dur td|S)Nzcannot determine number of cpus)os cpu_countNotImplementedError)selfZnumrrr r)s zBaseContext.cpu_countcCs( ddlm}||d}||S)Nr) SyncManagerctx)Zmanagersr get_contextstart)rrmrrr Manager1s  zBaseContext.ManagerTcC ddlm}||S)Nr)Pipe) connectionr)rZduplexrrrr r< zBaseContext.PipecC ddlm}||dS)Nr)Lockr) synchronizer"r)rr"rrr r"A zBaseContext.LockcCr!)Nr)RLockr)r#r%r)rr%rrr r%Fr$zBaseContext.RLockNcC ddlm}|||dS)Nr) Conditionr)r#r'r)rlockr'rrr r'K zBaseContext.ConditionrcCr&)Nr) Semaphorer)r#r*r)rvaluer*rrr r*Pr)zBaseContext.SemaphorecCr&)Nr)BoundedSemaphorer)r#r,r)rr+r,rrr r,Ur)zBaseContext.BoundedSemaphorecCr!)Nr)Eventr)r#r-r)rr-rrr r-Zr$zBaseContext.EventcC" ddlm}|||||dS)Nr)Barrierr)r#r/r)rZpartiesactionZtimeoutr/rrr r/_s zBaseContext.BarrierrcCr&)Nr)Queuer)queuesr1r)rmaxsizer1rrr r1dr)zBaseContext.QueuecCr&)Nr) JoinableQueuer)r2r4r)rr3r4rrr r4ir)zBaseContext.JoinableQueuecCr!)Nr) SimpleQueuer)r2r5r)rr5rrr r5nr$zBaseContext.SimpleQueuercCs$ ddlm}||||||dS)Nr)Pool)context)Zpoolr6r)rZ processesZ initializerZinitargsZmaxtasksperchildr6rrr r6ss   zBaseContext.PoolcGs ddlm}||g|RS)Nr)RawValue) sharedctypesr8)rtypecode_or_typeargsr8rrr r8zr)zBaseContext.RawValuecCs ddlm}|||S)Nr)RawArray)r9r<)rr:size_or_initializerr<rrr r<s  zBaseContext.RawArray)r(cGs* ddlm}||g|R||dS)Nr)Valuer(r)r9r>r)rr:r(r;r>rrr r>s  zBaseContext.ValuecCr.)Nr)Arrayr?)r9r@r)rr:r=r(r@rrr r@s  zBaseContext.ArraycCs6 tjdkrttddrddlm}|dSdSdS)Nwin32frozenFr)freeze_support)sysplatformgetattrspawnrC)rrCrrr rCs   zBaseContext.freeze_supportcCs ddlm}|S)Nr) get_logger)utilrH)rrHrrr rHs zBaseContext.get_loggercCr)Nr) log_to_stderr)rIrJ)rlevelrJrrr rJr zBaseContext.log_to_stderrcCs ddlm}dS)Nr)r)r)rrrrr allow_connection_picklingsz%BaseContext.allow_connection_picklingcC ddlm}||dS)Nr)set_executable)rGrO)r executablerOrrr rOs  zBaseContext.set_executablecCrN)Nr)set_forkserver_preload) forkserverrQ)rZ module_namesrQrrr rQs  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)_namerZ allow_nonerrr get_start_methodszBaseContext.get_start_methodcCstd)Nz+cannot set start method of concrete context)rUrrWZforcerrr set_start_methodszBaseContext.set_start_methodcCs tdSNr)globalsgetrrrr reducers zBaseContext.reducercCs|td<dSr^)r_)rrrrr rbcCdSrXrrarrr rVszBaseContext._check_available)TrX)r)NN)r)NNrNF)+r r r rrrr staticmethodrZcurrent_processZparent_processZactive_childrenrrrr"r%r'r*r,r-r/r1r4r5r6r8r<r>r@rCrHrJrMrOrQrr[r]propertyrbsetterrVrrrr rsT                 rc@s(eZdZdZeddZeddZdS)ProcessNcCstj|SrX)_default_contextrri_Popen) process_objrrr rkszProcess._PopencCstjSrX)rjrri _after_forkrrrr rmrczProcess._after_forkr r r _start_methodrfrkrmrrrr ris  ricsFeZdZeZddZd fdd ZdddZdd d Zd d ZZ S)DefaultContextcCs||_d|_dSrX)rj_actual_context)rr7rrr __init__s zDefaultContext.__init__Ncs,|dur|jdur |j|_|jSt|SrX)rqrjsuperr)rrW __class__rr rs   zDefaultContext.get_contextFcCs<|jdur |s td|dur|rd|_dS|||_dS)Nzcontext has already been set)rq RuntimeErrorrr\rrr r]s  zDefaultContext.set_start_methodcCs"|jdur |r dS|j|_|jjSrX)rqrjrYrZrrr r[s zDefaultContext.get_start_methodcCs>tjdkrdgStjdkrddgnddg}tjr|d|S)NrArGdarwinforkrR)rDrErHAVE_SEND_HANDLEappend)rmethodsrrr get_all_start_methodss  z$DefaultContext.get_all_start_methodsrXre) r r r rirrrr]r[r| __classcell__rrrtr rps  rprAc@eZdZdZeddZdS) ForkProcessrxcCddlm}||SNr)Popen)Z popen_forkrrlrrrr rk zForkProcess._PopenNr r r rorfrkrrrr rrc@(eZdZdZeddZeddZdS) SpawnProcessrGcCrr)Zpopen_spawn_posixrrrrr rkrSpawnProcess._PopencCrdrXrrrrr rm"SpawnProcess._after_forkNrnrrrr r  rc@r~)ForkServerProcessrRcCrr)Zpopen_forkserverrrrrr rk)rzForkServerProcess._PopenNrrrrr r'rrc@eZdZdZeZdS) ForkContextrxN)r r r rYrrirrrr r.rc@r SpawnContextrGNr r r rYrrirrrr r2rrc@seZdZdZeZddZdS)ForkServerContextrRcCstjstddS)Nz%forkserver start method not available)rryrUrarrr rV9sz"ForkServerContext._check_availableN)r r r rYrrirVrrrr r6s r)rxrGrRrwrGrxc@r)rrGcCrr)Zpopen_spawn_win32rrrrr rkMrrcCrdrXrrrrr rmRrrNrnrrrr rKrc@rrrrrrr rWrcCst|t_dSrX)rSrjrq)rWrrr _force_start_methoddsrcCs ttddS)Nspawning_popen)rF_tlsrrrr get_spawning_popenms rcCs |t_dSrX)rr)popenrrr set_spawning_popenps rcCs tdurtdt|jdS)NzF%s objects should only be shared between processes through inheritance)rrvtyper )objrrr assert_spawningss r) rrDZ threadingrLrr__all__ ExceptionrrrrobjectrZ BaseProcessrirprErrrrrrrSrjrZlocalrrrrrrrr sL  ? ,