e SrSrSSKrSSKJr SSKrSSKrSSKrSSK J r SSK r SSK r SSK Jr SSKrSSKrSSKJr \ R&"5rSq"S S 5rS r\ R0"\5 S rS r"SS\5r"SS5rSr"SS\5r "SS\5r!"SS\5r""SS\ 5r#Sr$S&Sjr%S'Sjr&"SS\ RN5r(Sq)Sq*S r+S!r,"S"S#\RZ5r."S$S%\R^5r0g)(a- Implements ProcessPoolExecutor. The following diagram and text describe the data-flow through the system: |======================= In-process =====================|== Out-of-process ==| +----------+ +----------+ +--------+ +-----------+ +---------+ | | => | Work Ids | | | | Call Q | | Process | | | +----------+ | | +-----------+ | Pool | | | | ... | | | | ... | +---------+ | | | 6 | => | | => | 5, call() | => | | | | | 7 | | | | ... | | | | Process | | ... | | Local | +-----------+ | Process | | Pool | +----------+ | Worker | | #1..n | | Executor | | Thread | | | | | +----------- + | | +-----------+ | | | | <=> | Work Items | <=> | | <= | Result Q | <= | | | | +------------+ | | +-----------+ | | | | | 6: call() | | | | ... | | | | | | future | | | | 4, result | | | | | | ... | | | | 3, except | | | +----------+ +------------+ +--------+ +-----------+ +---------+ Executor.submit() called: - creates a uniquely numbered _WorkItem and adds it to the "Work Items" dict - adds the id of the _WorkItem to the "Work Ids" queue Local worker thread: - reads work ids from the "Work Ids" queue and looks up the corresponding WorkItem from the "Work Items" dict: if the work item has been cancelled then it is simply removed from the dict, otherwise it is repackaged as a _CallItem and put in the "Call Q". New _CallItems are put in the "Call Q" until "Call Q" is full. NOTE: the size of the "Call Q" is kept small because calls placed in the "Call Q" can no longer be cancelled with Future.cancel(). - reads _ResultItems from "Result Q", updates the future stored in the "Work Items" dict and deletes the dict entry Process #1..n: - reads _CallItems from "Call Q", executes the calls, and puts the resulting _ResultItems in "Result Q" z"Brian Quinlan (brian@sweetapp.com)N)_base)Queue)partial)format_exceptionFc,\rSrSrSrSrSrSrSrg) _ThreadWakeupDcSUl[R"5Ul[R "SS9uUlUlg)NF)duplex)_closed threadingLock_lockmpPipe_reader_writerselfs @/opt/imh/python3.13/lib/python3.13/concurrent/futures/process.py__init___ThreadWakeup.__init__Es. ^^% %'WWE%:" dlcUR UR(d;SUlURR5 URR5 SSS5 g!,(df  g=fNT)rr rcloserrs rr_ThreadWakeup.closeJsC ZZ<<#  ""$ ""$ ZZs A A## A1cUR UR(dURRS5 SSS5 g!,(df  g=f)Nr)rr r send_bytesrs rwakeup_ThreadWakeup.wakeupVs, ZZ<< '',ZZs -A AcUR(a [S5eURR5(a<URR 5 URR5(aM;gg)Nz!operation on closed _ThreadWakeup)r RuntimeErrorrpoll recv_bytesrs rclear_ThreadWakeup.clear[sM <<BC Cll!! LL # # %ll!!r)r rrrN) __name__ __module__ __qualname____firstlineno__rrr r&__static_attributes__rrrrDs; %- &rrcSq[[R55nUHupUR 5 M UHup1UR 5 M gr)_global_shutdownlist_threads_wakeupsitemsr join)r2_ thread_wakeupts r _python_exitr7bsL !'') *E!" r=c \rSrSrSrSrSrg)_RemoteTracebackcXlgNtb)rr@s rr_RemoteTraceback.__init__srcUR$r>r?rs r__str___RemoteTraceback.__str__s wwrr?N)r(r)r*r+rrCr,r-rrr;r;s rr;c \rSrSrSrSrSrg)_ExceptionWithTracebackcSR[[U5X55nXlSURlSU-Ulg)Nz """ %s""")r3rtypeexc __traceback__r@)rrKr@s rr _ExceptionWithTraceback.__init__s; WW%d3i9 :"& 2%rc>[URUR44$r>) _rebuild_excrKr@rs r __reduce__"_ExceptionWithTraceback.__reduce__sdhh000rrKr@N)r(r)r*r+rrPr,r-rrrFrFs &1rrFc&[U5UlU$r>)r; __cause__rRs rrOrOs$R(CM Jrc\rSrSrSrSrg) _WorkItemc4XlX lX0lX@lgr>)futurefnargskwargs)rrYrZr[r\s rr_WorkItem.__init__s   r)r[rZrYr\Nr(r)r*r+rr,r-rrrVrVrrVc\rSrSrSSjrSrg) _ResultItemNc4XlX lX0lX@lgr>)work_id exceptionresultexit_pid)rrdrerfrgs rr_ResultItem.__init__s "  r)rergrfrdNNNr^r-rrraras!rrac\rSrSrSrSrg) _CallItemc4XlX lX0lX@lgr>)rdrZr[r\)rrdrZr[r\s rr_CallItem.__init__s   r)r[rZr\rdNr^r-rrrkrkr_rrkc<^\rSrSrSrSU4SjjrU4SjrSrU=r$) _SafeQueuez=Safe Queue set exception to the future object linked to a jobc8>X0lX@l[TU] XS9 g)N)ctx)pending_work_itemsr5superr)rmax_sizersrtr5 __class__s rr_SafeQueue.__init__s"4* +rc>[U[5(a[[U5XR5n[ SR SRU555UlURRURS5nURR5 UbURRU5 gg[ TU]EX5 g)Nz """ {}"""rI) isinstancerkrrJrLr;formatr3rTrtpoprdr5r rY set_exceptionru_on_queue_feeder_error)reobjr@ work_itemrws rr~!_SafeQueue._on_queue_feeder_errors c9 % %!$q'1oo>B*>+@+@+MNAK//33CKKFI    % % '$  ..q1% G *1 2r)rtr5)r) r(r)r*r+__doc__rr~r, __classcell__rws@rrprpsG, 3 3rrpc6UVs/sHo "U6PM sn$s snf)zProcesses a chunk of an iterable passed to map. Runs the function passed to map() on a chunk of the iterable passed to map. This function is run in a separate process. r-)rZchunkr[s r_process_chunkrs #( (%$BI% (( (sc UR[XX4S95 g![a8n[XUR5nUR[XUS95 SnAgSnAff=f)z.Safely send back the given result or exception)rfrergrergN)putra BaseExceptionrFrL) result_queuerdrfrergrrKs r_sendback_resultrs`9W/8M N 9%a9W.68 9 99s A.AAc6UbU"U6 SnSnUR SS9nUc%UR [ R"55 gUbUS- nXT:a[ R"5nUR"UR0URD6n[XRUUS9 AAUbgM![a! [RRSSS9 gf=f![a4n [XR5n [XRU US 9 Sn A NnSn A ff=f) aEvaluates calls from call_queue and places the results in result_queue. This worker is run in a separate process. Args: call_queue: A ctx.Queue of _CallItems that will be read and evaluated by the worker. result_queue: A ctx.Queue of _ResultItems that will written to by the worker. initializer: A callable initializer, or None initargs: A tuple of args for the initializer NzException in initializer:T)exc_inforblockr8)rfrgr)rrLOGGERcriticalgetrosgetpidrZr[r\rrdrFrL) call_queuer initializerinitargs max_tasks num_tasksrg call_itemrrrKs r_process_workerrs$   " IH NNN.     RYY[ )   NI%99;  innA 0@0@AA \+<+URUlURUlUR[R R 4Sjn[R"X5Ul URUl URUl URUlUR UlUR$UlUR(Ul[,TU]]5 g)Nc4U"S5 UR5 g)Nz?Executor collected: triggering callback for QueueManager wakeup)r )r4r5 mp_util_debugs r weakref_cb3_ExecutorManagerThread.__init__..weakref_cb*s 1 2  "r)_executor_manager_thread_wakeupr5_shutdown_lock shutdown_lockrutildebugweakrefrefexecutor_reference _processes processes _call_queuer _result_queuer _work_idswork_ids_queue_max_tasks_per_childmax_tasks_per_child_pending_work_itemsrtrur)rexecutorrrws rr_ExecutorManagerThread.__init__s &EE%44&*%7%7%'WW]] ##*++h"C",,#..%22'00$,#@#@ #+">"> rc6UR5 UR 5up4nU(aURU5 gUbUR U5 UR SLnU(a5URRUR 5nUR5 AUR5=n(aHU(a&UR UR5 SSS5 OURR5 AUR5(aBUR!5 UR5 UR"(dUR%5 gGMU![a&n[U5nURU5 SnAgSnAff=f!,(df  N=fr>)add_call_item_to_queuerrterminate_brokenwait_result_broken_or_wakeupprocess_result_itemrgrr|r3rr_adjust_process_count_idle_worker_semaphorereleaseis_shutting_downflag_executor_shutting_downrtjoin_executor_internals)rrKcause result_item is_brokenprocess_exitedprs rrun_ExecutorManagerThread.runJsZ ++- -1,M,M,O )KE%%e,&((5!,!5!5T!A!**;+?+?@AFFH #668888%!//$::<0/!77??A $$&&002 ++-..002_ ! (-%%e, 00/s#EF  F!FF FcURR5(agURRSS9nURUnUR R 5(aEURR[UURURUR5SS9 OURU MM![Ra gf=f)NTFr)rfullrrrtrYset_running_or_notify_cancelrrkrZr[r\queueEmpty)rrdrs rr-_ExecutorManagerThread.add_call_item_to_queue~s##%% --111>!33G< ##@@BBOO'' '2;,,2;..2;2B2B)D/3 (4 //8% ;;  sCCCc*URRnURR(aeURRnX/n[ UR R 55Vs/sHoDRPM nn[RRX5-5nSnSnSn X;aUR5n SnOX&;aSnURR5 XU4$s snf![an [U 5nSn A N=Sn A ff=fNTF)rrr5r r0rvaluessentinelr connectionwaitrecvrrr&) r result_reader wakeup_readerreadersrworker_sentinelsreadyrrrrKs rr3_ExecutorManagerThread.wait_result_broken_or_wakeups ))11 %%----**22  004T^^5J5J5L0MN0M1JJ0MN ""7#=>   ! .+002 !  #I   "u,,%O! .(- .s2C.6C33 D= D  DcURRURS5nUb]UR(a&URR UR5 gURR UR5 ggr>)rtr|rdrerYr} set_resultrf)rrrs rr*_ExecutorManagerThread.process_result_itemsj ++// 0C0CTJ  $$  ..{/D/DE  ++K,>,>? !rcjUR5n[=(d USL=(d UR$r>)rr/_shutdown_thread)rrs rr'_ExecutorManagerThread.is_shutting_downs4**, !-H$4-,, .rcHUR5nUbSUlSUlSn[S5nUb#[ SSR U5S35UlURR5H"upEURRU5 AM$ URR5 URR5HnUR!5 M UR"R%5 UR'SS9 g![Ra Nf=f)NzKA child process terminated abruptly, the process pool is not usable anymoreTz^A process in the process pool was terminated abruptly while the future was running or pending.z ''' rIz''')broken)r_brokenrBrokenProcessPoolr;r3rTrtr2rYr}rInvalidStateErrorr&rr terminater_terminate_broken_join_executor_internals)rrrbperdrrs rr(_ExecutorManagerThread._terminate_brokens **,  !1H )-H %H !67  ,"''%.)-/CM#'"9"9"?"?"A G   ..s3#B %%'&&(A KKM) ))+ %%T%2%**    s5D  D! D!crUR URU5 SSS5 g!,(df  g=fr>)rr)rrs rr'_ExecutorManagerThread.terminate_brokens%     " "5 )  s( 6c|UR5nUbSUlUR(an0nURR 5H*up4UR R 5(aM&XBU'M, X lURR5 Mgg![Ra Of=fSUlgr) rr_cancel_pending_futuresrtr2rYcancelr get_nowaitrr)rrnew_pending_work_itemsrdrs rr2_ExecutorManagerThread.flag_executor_shutting_downs**,  (,H %//*,&*.*A*A*G*G*I&G$++2244:Cw7+J+A'++6680 !;;490s>BB32B3c8UR5nSnX!:agUR5S:aR[X- 5H$nURRS5 US- nM& X!:aUR5S:aMPgggg![R a  M7f=f)Nrr8)get_n_children_aliveranger put_nowaitrFull)rn_children_to_stopn_sentinels_sentis rshutdown_workers'_ExecutorManagerThread.shutdown_workerss!668 4--/!3-@AOO..t4$)$B 4--/!3535 zzs BBBcpUR UR5 SSS5 g!,(df  g=fr>)rrrs rr._ExecutorManagerThread.join_executor_internals%s#     ) ) +  s' 5c^U(dUR5 URR5 URR5 URR5 UR R 5H*nU(aUR5 UR5 M, gr>) rrr join_threadr5rrrr3)rrrs rr/_ExecutorManagerThread._join_executor_internals)ss  ! ! #  ##%   "&&(A FFH)rcV[SURR555$)Nc3@# UHoR5v M g7fr>)is_alive).0rs r >_ExecutorManagerThread.get_n_children_alive..<sA)@A::<<)@s)sumrrrs rr+_ExecutorManagerThread.get_n_children_alive:s A)>)>)@AAAr) rrrrtrrrr5r)F)r(r)r*r+rrrrrrrrrrrrrrr,rrs@rrrsT ,\2h.-< @.-3^*94 ,"BBrrc6[(a[(a[[5eSqSSKn[ R "S5nUS:XagUS:agSU-q[[5e![a Sq[[5ef=f![[4a gf=f)NTrzxThis Python build lacks multiprocessing.synchronize, usually due to named semaphores being unavailable on this platform.SC_SEM_NSEMS_MAXz@system provides too few semaphores (%d available, 256 necessary)) _system_limits_checked_system_limitedNotImplementedErrormultiprocessing.synchronize ImportErrorrsysconfAttributeError ValueError)multiprocessing nsems_maxs r_check_system_limitsrCs ?%o6 6!3*JJ12 B C 46?@O o ..+ 3 F "/22 3 J 'sA&B&BBBc## UH7nUR5 U(dMUR5v U(aMM9 g7f)z Specialized implementation of itertools.chain.from_iterable. Each item in *iterable* should be a list. This function is careful not to keep references to yielded objects. N)reverser|)iterableelements r_chain_from_iterable_of_listsr!cs3 g++- gsAAAc\rSrSrSrSrg)riozm Raised when a process in a ProcessPoolExecutor terminated abruptly while a future was in the running state. r-N)r(r)r*r+rr,r-rrrrosrrc ^\rSrSrSSS.SjjrSrSrSrSrS r \ RRR\ l SS S .U4S jjr SS S.Sjjr\ RRR\l SrU=r$)ProcessPoolExecutorivN)rc[5 UcW[R"5=(d SUl[R S:Xa[ [UR5UlOGUS::a [S5e[R S:XaU[:a[S[35eXlUc/Ub[R"S5nO[R"5nX l URRSS 9S :gUl Ub[U5(d [S 5eX0lX@lUbY[%U[&5(d [S 5eUS::a [S 5eURRSS 9S :Xa [S5eXPlSUl0UlSUl[0R2"5Ul[0R6"S5UlSUlSUl0UlSUl [C5Ul"UR[F-n[IX`RUR>URDS9Ul%SURJl&URO5Ul([RRT"5Ul+g)aInitializes a new ProcessPoolExecutor instance. Args: max_workers: The maximum number of processes that can be used to execute the given calls. If None or not given then as many worker processes will be created as the machine has processors. mp_context: A multiprocessing context to launch the workers created using the multiprocessing.get_context('start method') API. This object should provide SimpleQueue, Queue and Process. initializer: A callable used to initialize worker processes. initargs: A tuple of arguments to pass to the initializer. max_tasks_per_child: The maximum number of tasks a worker process can complete before it will exit and be replaced with a fresh worker process. The default of None means worker process will live as long as the executor. Requires a non-'fork' mp_context start method. When given, we default to using 'spawn' if no mp_context is supplied. Nr8win32rz"max_workers must be greater than 0zmax_workers must be <= spawnF) allow_noneforkzinitializer must be a callablez&max_tasks_per_child must be an integerz max_tasks_per_child must be >= 1zpmax_tasks_per_child is incompatible with the 'fork' multiprocessing start method; supply a different mp_context.)rvrsrtr5T),rrprocess_cpu_count _max_workerssysplatformmin_MAX_WINDOWS_WORKERSrr get_context _mp_contextget_start_method#_safe_to_dynamically_spawn_childrencallable TypeError _initializer _initargsrzintr_executor_manager_threadrrr rr Semaphorerr _queue_countrrrrEXTRA_QUEUED_CALLSrpr _ignore_epipe SimpleQueuerrrr)r max_workers mp_contextrrr queue_sizes rrProcessPoolExecutor.__init__wsV(    " 4 4 6 ;!D ||w&$'(<(,(9(9%;!a !EFF,,')22 -.B-CDFF!,   ".^^G4 ^^- %  11U1CvM 0  "8K+@+@<= ='!  *1377 HII$) !CDD00E0BfL "CDD%8!)-%!&'nn.&/&9&9!&<# #% ',$0=, &&);; %%5%5#77>>@*.&'335rcURciUR(dUR5 [U5UlURR 5 UR [ UR'ggr>)r9r3_launch_processesrstartrr1rs r_start_executor_manager_thread2ProcessPoolExecutor._start_executor_manager_threads`  ( ( 0;;&&(,B4,HD )  ) ) / / 144 T:: ; 1rcURRSS9(ag[UR5nXR:aUR 5 gg)NF)blocking)racquirelenrr+_spawn_process)r process_counts rr)ProcessPoolExecutor._adjust_process_countsI  & & . . . > DOO, ,, ,    ! -rcUR(aS5e[[UR5UR5HnUR 5 M g)NzhProcesses cannot be fork()ed after the thread has started, deadlock in the child processes could result.)r9rrKrr+rL)rr4s rrD%ProcessPoolExecutor._launch_processessO00 A@ A0s4??+T->->?A    !@rcURR[URURUR UR UR4S9nUR5 XRUR'g)N)targetr[) r1Processrrrr6r7rrErpid)rrs rrL"ProcessPoolExecutor._spawn_processsk    $ $"""$$##..++ - % .  !"rcUR UR(a[UR5eUR(a [ S5e[ (a [ S5e[ R"5n[XAX#5nXPRUR'URRUR5 U=RS- sl URR5 UR(aUR!5 UR#5 UsSSS5 $!,(df  g=f)Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdownr8)rrrrr#r/rFuturerVrr;rrrr r3rrF)rrZr[r\fws rsubmitProcessPoolExecutor.submits  ||' 55$$"#OPP"$:;; A!.A:; $ $T%6%6 7 NN  t00 1    "   0 0 7 7 977**,  / / 1+! s DD// D=r8)timeout chunksizec>US:a [S5e[TU] [[U5[ R "[U6U5US9n[U5$)aReturns an iterator equivalent to map(fn, iter). Args: fn: A callable that will take as many arguments as there are passed iterables. timeout: The maximum number of seconds to wait. If None, then there is no limit on the wait time. chunksize: If greater than one, the iterables will be chopped into chunks of size chunksize and submitted to the process pool. If set to one, the items in the list will be sent one at a time. Returns: An iterator equivalent to: map(func, *iterables) but the calls may be evaluated out-of-order. Raises: TimeoutError: If the entire result iterator could not be generated before the given timeout. Exception: If fn(*args) raises for any values. r8zchunksize must be >= 1.)r\) rrumaprr itertoolsbatchedzipr!)rrZr\r] iterablesresultsrws rr_ProcessPoolExecutor.map(sX* q=67 7'+gnb9'//YK&-/-W55rF)cancel_futurescUR X lSUlURbURR 5 SSS5 UR b!U(aUR R 5 SUlSUlURb!U(aURR5 SUlSUl SUlg!,(df  N=fr) rrrrr r9r3rrrr)rrrfs rshutdownProcessPoolExecutor.shutdownEs  +9 ($(D !33?44;;= !  ( ( 4  ) ) . . 0)-%    )d    $ $ &!/3,#! s 5C  C)rrrr9rrr7r6rr+r1rrr;rr3rrr)NNNr-)T)r(r)r*r+rrFrrDrLrZrExecutorrr_rhr,rrs@rr$r$vs48,.j'GKj'X5 "" #.^^**22FN*.!66:4E4(~~..66Hrr$rir>)1r __author__rconcurrent.futuresrrrrmultiprocessing.connectionmultiprocessing.queuesrr r functoolsrr`r, tracebackrWeakKeyDictionaryr1r/rr7_register_atexitr<r/ Exceptionr;rFrOobjectrVrarkrprrrThreadrrrrr!BrokenExecutorrrjr$r-rrrws6(T2 $ "( &,,.&&< <( y 1 1!&!33, )DH" 93llBY--lB^ /@  ,,c7%..c7r