a  ze+@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__rrrK/opt/bitninja-python-dojo/embedded/lib/python3.9/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}|durtdn|SdS)Nzcannot determine number of cpus)os cpu_countNotImplementedError)selfnumrrr r)s zBaseContext.cpu_countcCs&ddlm}||d}||S)Nr) SyncManagerctx)managersr get_contextstart)rrmrrr Manager1s zBaseContext.ManagerTcCsddlm}||S)Nr)Pipe) connectionr)rduplexrrrr r<s zBaseContext.PipecCsddlm}||dS)Nr)Lockr) synchronizer r)rr rrr r As zBaseContext.LockcCsddlm}||dS)Nr)RLockr)r!r"r)rr"rrr r"Fs zBaseContext.RLockNcCsddlm}|||dS)Nr) Conditionr)r!r#r)rlockr#rrr r#Ks zBaseContext.ConditionrcCsddlm}|||dS)Nr) Semaphorer)r!r%r)rvaluer%rrr r%Ps zBaseContext.SemaphorecCsddlm}|||dS)Nr)BoundedSemaphorer)r!r'r)rr&r'rrr r'Us zBaseContext.BoundedSemaphorecCsddlm}||dS)Nr)Eventr)r!r(r)rr(rrr r(Zs zBaseContext.EventcCs ddlm}|||||dS)Nr)Barrierr)r!r)r)rpartiesactiontimeoutr)rrr r)_s zBaseContext.BarrierrcCsddlm}|||dS)Nr)Queuer)queuesr-r)rmaxsizer-rrr r-ds zBaseContext.QueuecCsddlm}|||dS)Nr) JoinableQueuer)r.r0r)rr/r0rrr r0is zBaseContext.JoinableQueuecCsddlm}||dS)Nr) SimpleQueuer)r.r1r)rr1rrr r1ns zBaseContext.SimpleQueuercCs"ddlm}||||||dS)Nr)Pool)context)poolr2r)r processes initializerinitargsmaxtasksperchildr2rrr r2ss  zBaseContext.PoolcGsddlm}||g|RS)Nr)RawValue) sharedctypesr9)rtypecode_or_typeargsr9rrr r9zs zBaseContext.RawValuecCsddlm}|||S)Nr)RawArray)r:r=)rr;size_or_initializerr=rrr r=s zBaseContext.RawArray)r$cGs(ddlm}||g|R||dS)Nr)Valuer$r)r:r?r)rr;r$r<r?rrr r?s zBaseContext.ValuecCs ddlm}|||||dS)Nr)Arrayr@)r:rAr)rr;r>r$rArrr rAs zBaseContext.ArraycCs,tjdkr(ttddr(ddlm}|dS)Nwin32frozenFr)freeze_support)sysplatformgetattrspawnrD)rrDrrr rDs zBaseContext.freeze_supportcCsddlm}|S)Nr) get_logger)utilrI)rrIrrr rIs zBaseContext.get_loggercCsddlm}||S)Nr) log_to_stderr)rJrK)rlevelrKrrr rKs zBaseContext.log_to_stderrcCsddlm}dS)Nr)r)r)rrrrr allow_connection_picklingsz%BaseContext.allow_connection_picklingcCsddlm}||dS)Nr)set_executable)rHrO)r executablerOrrr rOs zBaseContext.set_executablecCsddlm}||dS)Nr)set_forkserver_preload) forkserverrQ)r module_namesrQrrr rQs z"BaseContext.set_forkserver_preloadcCsF|dur |Sz t|}Wn ty8td|dYn0||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_methodcCs tddS)Nz+cannot set start method of concrete context)rVrrXforcerrr set_start_methodszBaseContext.set_start_methodcCs tdSNr)globalsgetrrrr reducerszBaseContext.reducercCs|td<dSra)rb)rrrrr rescCsdSrYrrdrrr rWszBaseContext._check_available)T)N)r)r)NN)r)r)NNrN)N)N)F)F)+rr r rr r r staticmethodrcurrent_processparent_processactive_childrenrrrr r"r#r%r'r(r)r-r0r1r2r9r=r?rArDrIrKrNrOrQrr]r`propertyresetterrWrrrr rsR                rc@seZdZdZeddZdS)ProcessNcCstj|SrY)_default_contextrrl_Popen) process_objrrr rnszProcess._Popenrr r _start_methodrfrnrrrr rlsrlcsFeZdZeZddZd fdd ZdddZdd d Zd d ZZ S)DefaultContextcCs||_d|_dSrY)rm_actual_context)rr3rrr __init__szDefaultContext.__init__Ncs0|dur |jdur|j|_|jSt|SdSrY)rsrmsuperr)rrX __class__rr rs  zDefaultContext.get_contextFcCs<|jdur|std|dur,|r,d|_dS|||_dS)Nzcontext has already been set)rs RuntimeErrorrr^rrr r`s  zDefaultContext.set_start_methodcCs"|jdur|rdS|j|_|jjSrY)rsrmrZr[rrr r]s  zDefaultContext.get_start_methodcCsBtjdkrdgStjdkr"ddgnddg}tjr:|d|SdS)NrBrHdarwinforkrR)rErFrHAVE_SEND_HANDLEappend)rmethodsrrr get_all_start_methodss   z$DefaultContext.get_all_start_methods)N)F)F) rr r rlrtrr`r]r~ __classcell__rrrvr rrs   rrrBc@seZdZdZeddZdS) ForkProcessrzcCsddlm}||SNr)Popen) popen_forkrrorrrr rns zForkProcess._PopenNrprrrr rsrc@seZdZdZeddZdS) SpawnProcessrHcCsddlm}||Sr)popen_spawn_posixrrrrr rns SpawnProcess._PopenNrprrrr rsrc@seZdZdZeddZdS)ForkServerProcessrRcCsddlm}||Sr)popen_forkserverrrrrr rn s zForkServerProcess._PopenNrprrrr rsrc@seZdZdZeZdS) ForkContextrzN)rr r rZrrlrrrr r%src@seZdZdZeZdS SpawnContextrHNrr r rZrrlrrrr r)src@seZdZdZeZddZdS)ForkServerContextrRcCstjstddS)Nz%forkserver start method not available)rr{rVrdrrr rW0sz"ForkServerContext._check_availableN)rr r rZrrlrWrrrr r-sr)rzrHrRryrHrzc@seZdZdZeddZdS)rrHcCsddlm}||Sr)Zpopen_spawn_win32rrrrr rnDs rNrprrrr rBsc@seZdZdZeZdSrrrrrr rIscCst|t_dSrY)rTrmrs)rXrrr _force_start_methodVsrcCs ttddS)Nspawning_popen)rG_tlsrrrr get_spawning_popen_srcCs |t_dSrY)rr)popenrrr set_spawning_popenbsrcCs tdurtdt|jdS)NzF%s objects should only be shared between processes through inheritance)rrxtyper)objrrr assert_spawninges  r) rrE threadingrMrr__all__ Exceptionrr r robjectr BaseProcessrlrrrFrrrrrrrTrmrlocalrrrrrrrr sJ  ?,