U e5d+@sddlZddlZddlZddlmZddlmZdZGdddeZGdd d eZ Gd d d eZ Gd d d eZ Gddde Z GdddejZGddde ZejdkrRGdddejZGdddejZGdddejZGddde ZGddde ZGdd d e Zeeed!Zejd"krDeed#Zn eed$Zn8Gd%ddejZGd&dde Zd#eiZeed#Zd'd(ZeZd)d*Zd+d,Zd-d.ZdS)/N)process) reductionc@s eZdZdS) ProcessErrorN__name__ __module__ __qualname__rrr//usr/lib64/python3.8/multiprocessing/context.pyrsrc@s eZdZdS)BufferTooShortNrrrrr r sr c@s eZdZdS) TimeoutErrorNrrrrr r sr c@s eZdZdS)AuthenticationErrorNrrrrr rsrc@sXeZdZeZeZeZeZeej Z eej Z eej Z ddZ ddZ dCddZdd Zd d ZdDd dZdEddZdFddZddZdGddZdHddZdIddZddZdJd d!Zd"d#Zd$d%Zdd&d'd(Zdd&d)d*Zd+d,Zd-d.ZdKd/d0Z d1d2Z!d3d4Z"d5d6Z#dLd7d8Z$dMd:d;Z%dNdd?Z(e(j)d@d?Z(dAdBZ*d S)O BaseContextcCs"t}|dkrtdn|SdS)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.ManagerTcCsddlm}||S)Nr)Pipe) connectionr)rZduplexrrrr r<s zBaseContext.PipecCsddlm}||dS)Nr)Lockr) synchronizerr)rrrrr rAs zBaseContext.LockcCsddlm}||dS)Nr)RLockr)rrr)rrrrr rFs zBaseContext.RLockNcCsddlm}|||dS)Nr) Conditionr)rr r)rlockr rrr r Ks zBaseContext.ConditionrcCsddlm}|||dS)Nr) Semaphorer)rr"r)rvaluer"rrr r"Ps zBaseContext.SemaphorecCsddlm}|||dS)Nr)BoundedSemaphorer)rr$r)rr#r$rrr r$Us zBaseContext.BoundedSemaphorecCsddlm}||dS)Nr)Eventr)rr%r)rr%rrr r%Zs zBaseContext.EventcCs ddlm}|||||dS)Nr)Barrierr)rr&r)rZpartiesactionZtimeoutr&rrr r&_s zBaseContext.BarrierrcCsddlm}|||dS)Nr)Queuer)queuesr(r)rmaxsizer(rrr r(ds zBaseContext.QueuecCsddlm}|||dS)Nr) JoinableQueuer)r)r+r)rr*r+rrr r+is zBaseContext.JoinableQueuecCsddlm}||dS)Nr) SimpleQueuer)r)r,r)rr,rrr r,ns zBaseContext.SimpleQueuercCs"ddlm}||||||dS)Nr)Pool)context)Zpoolr-r)rZ processesZ initializerZinitargsZmaxtasksperchildr-rrr r-ss  zBaseContext.PoolcGsddlm}||f|S)Nr)RawValue) sharedctypesr/)rtypecode_or_typeargsr/rrr r/zs zBaseContext.RawValuecCsddlm}|||S)Nr)RawArray)r0r3)rr1size_or_initializerr3rrr r3s zBaseContext.RawArray)r!cGs&ddlm}||f|||dS)Nr)Valuer!r)r0r5r)rr1r!r2r5rrr r5s  zBaseContext.ValuecCs ddlm}|||||dS)Nr)Arrayr6)r0r7r)rr1r4r!r7rrr r7s zBaseContext.ArraycCs,tjdkr(ttddr(ddlm}|dS)Nwin32frozenFr)freeze_support)sysplatformgetattrspawnr:)rr:rrr r:s zBaseContext.freeze_supportcCsddlm}|S)Nr) get_logger)utilr?)rr?rrr r?s zBaseContext.get_loggercCsddlm}||S)Nr) log_to_stderr)r@rA)rlevelrArrr rAs zBaseContext.log_to_stderrcCsddlm}dS)Nr)r)r)rrrrr allow_connection_picklingsz%BaseContext.allow_connection_picklingcCsddlm}||dS)Nr)set_executable)r>rE)r executablerErrr rEs zBaseContext.set_executablecCsddlm}||dS)Nr)set_forkserver_preload) forkserverrG)rZ module_namesrGrrr rGs z"BaseContext.set_forkserver_preloadcCsH|dkr |Sz t|}Wn"tk r:td|dYnX||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_methodcCs tddS)Nz+cannot set start method of concrete context)rKrrMZforcerrr set_start_methodszBaseContext.set_start_methodcCs tdSNr)globalsgetrrrr reducerszBaseContext.reducercCs|td<dSrT)rU)rrrrr rXscCsdSrNrrWrrr rLszBaseContext._check_available)T)N)r)r)NN)r)r)NNrN)N)N)F)F)+rr r rr r r staticmethodrZcurrent_processZparent_processZactive_childrenrrrrrr r"r$r%r&r(r+r,r-r/r3r5r7r:r?rArDrErGrrQrSpropertyrXsetterrLrrrr rsR                rc@seZdZdZeddZdS)ProcessNcCstj|SrN)_default_contextrr\_Popen) process_objrrr r^szProcess._Popenrr r Z _start_methodrYr^rrrr r\sr\csFeZdZeZddZd fdd ZdddZdd d Zd d ZZ S)DefaultContextcCs||_d|_dSrN)r]_actual_context)rr.rrr __init__szDefaultContext.__init__Ncs0|dkr |jdkr|j|_|jSt|SdSrN)rbr]superr)rrM __class__rr rs  zDefaultContext.get_contextFcCs<|jdk r|std|dkr,|r,d|_dS|||_dS)Nzcontext has already been set)rb RuntimeErrorrrRrrr rSs  zDefaultContext.set_start_methodcCs"|jdkr|rdS|j|_|jjSrN)rbr]rOrPrrr rQs  zDefaultContext.get_start_methodcCsBtjdkrdgStjdkr"ddgnddg}tjr:|d|SdS)Nr8r>darwinforkrH)r;r<rHAVE_SEND_HANDLEappend)rmethodsrrr get_all_start_methodss   z$DefaultContext.get_all_start_methods)N)F)F) rr r r\rcrrSrQrm __classcell__rrrer ras   rar8c@seZdZdZeddZdS) ForkProcessricCsddlm}||SNr)Popen)Z popen_forkrqr_rqrrr r^s zForkProcess._PopenNr`rrrr rosroc@seZdZdZeddZdS) SpawnProcessr>cCsddlm}||Srp)Zpopen_spawn_posixrqrrrrr r^s SpawnProcess._PopenNr`rrrr rssrsc@seZdZdZeddZdS)ForkServerProcessrHcCsddlm}||Srp)Zpopen_forkserverrqrrrrr r^ s zForkServerProcess._PopenNr`rrrr rusruc@seZdZdZeZdS) ForkContextriN)rr r rOror\rrrr rv%srvc@seZdZdZeZdS SpawnContextr>Nrr r rOrsr\rrrr rx)srxc@seZdZdZeZddZdS)ForkServerContextrHcCstjstddS)Nz%forkserver start method not available)rrjrKrWrrr rL0sz"ForkServerContext._check_availableN)rr r rOrur\rLrrrr rz-srz)rir>rHrhr>ric@seZdZdZeddZdS)rsr>cCsddlm}||Srp)Zpopen_spawn_win32rqrrrrr r^Ds rtNr`rrrr rsBsc@seZdZdZeZdSrwryrrrr rxIscCst|t_dSrN)rIr]rb)rMrrr _force_start_methodVsr{cCs ttddS)Nspawning_popen)r=_tlsrrrr get_spawning_popen_sr~cCs |t_dSrN)r}r|)popenrrr set_spawning_popenbsrcCs tdkrtdt|jdS)NzF%s objects should only be shared between processes through inheritance)r~rgtyper)objrrr assert_spawninges  r) rr;Z threadingrCrr__all__ Exceptionrr r robjectrZ BaseProcessr\rar<rorsrurvrxrzrIr]r{Zlocalr}r~rrrrrr sL  ?,