+
    ii&  c                   s   R t Rt^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	]P                  ! 4       tRs]P                  ! 4       tR t]P                   ! ]4       ]! ]	R4      '       dQ   ]	P$                  ! ]P&                  ]P(                  ]P*                  R7       ]	P$                  ! ]P,                  R7        ! R	 R
4      t ! R R4      tR t ! R R]P4                  4      t ! R R]P8                  4      tR# )zImplements ThreadPoolExecutor.z"Brian Quinlan (brian@sweetapp.com))_baseNFc                  s   \         ;_uu_ 4        R sRRR4       \        \        P	                  4       4      p V  F  w  rVP                  R4       K  	  V  F  w  rVP                  4        K  	  R#   + '       g   i     Lf; iTN)_global_shutdown_lock	_shutdownZlist_threads_queuesitemsputjoin)r   tqs      2/usr/lib64/python3.14/concurrent/futures/thread.py_python_exitr      sZ    			 
&&()E	d 	  
	s   A00B 	register_at_fork)Zbeforeafter_in_childZafter_in_parent)r   c                   sH   a  ] tR t^/t o ]R 4       tR tR tR tR t	Rt
V tR# )WorkerContextc                sd   a aa Se   \        S4      '       g   \        R4      hV VV3R lpR pW43# )Nzinitializer must be a callablec                  s   < S ! SS4      # N )clsinitargsinitializers   r
   create_contextZ-WorkerContext.prepare.<locals>.create_context6   s    {H--    c                 s
    WV3# r   r   )fnargskwargs   &&&r
   resolve_taskZ+WorkerContext.prepare.<locals>.resolve_task8   s    f%%r   )ZcallableZ	TypeError)r   r   r   r   r   s   fff  r
   prepareZWorkerContext.prepare1   s3    "K(( @AA	.	&++r   c                    Wn         W n        R # r   r   r   )selfr   r   r   r
   __init__ZWorkerContext.__init__<   s    & r   c                sZ    V P                   e   V P                   ! V P                  !   R # R # r   r   r      &r
   
initializeZWorkerContext.initialize@   s%    'dmm, (r   c                s    R # r   r   r    r!   r
   finalizeZWorkerContext.finalizeD   s    r   c                s    Vw  r#pV! V/ VB # r   r   )r   taskr   r   r   s   &&   r
   runZWorkerContext.runG   s    &4"6""r   )r   r   N)__name__
__module____qualname____firstlineno__classmethodr   r   r"   r#   r%   __static_attributes____classdictcell__Z__classdict__   @r
   r   r   /   s0     , ,!-# #r   r   c                   sP   a  ] tR t^Lt o R tR t]! ]P                  4      t	Rt
V tR# )	_WorkItemc                r   r   futurer$   )r   r1   r$   r   r
   r   Z_WorkItem.__init__M   s    	r   c                s$   V P                   P                  4       '       g   R #  VP                  V P                  4      pV P                   P	                  V4       R #   \
         d)   pT P                   P                  T4       R p  R p?R # R p?ii ; ir   )r1   Zset_running_or_notify_cancelr%   r$   Z
set_resultBaseExceptionset_exception)r   ctxZresultZexcs   &&  r
   r%   Z_WorkItem.runQ   sl    {{7799	+WWTYY'F KK""6*  	KK%%c*D	s   A B'B

Br0   N)r&   r'   r(   r)   r   r%   r*   typesZGenericAliasZ__class_getitem__r+   r,   r-   r.   r
   r/   r/   L   s"     + $E$6$67r   r/   c                 s&    VP                  4           TP                  4       pTe   TP                  T4       ?K*  T ! 4       p\        '       g   Te   TP                  '       d0   Te   RTn        TP                  R4        TP                  4        R# ?K    \         dA    \        P                  P	                  R RR7       T ! 4       pTe   TP                  4         R# i ; i  \        P                   d=    T ! 4       pTe   TP                  P                  4        ?TP                  RR7      p ELi ; i  \         d%    \        P                  P	                  RRR7        Mi ; iTP                  4        R#   TP                  4        i ; i)zException in initializer:T)Zexc_infoN)ZblockzException in worker)r"   r2   r    ZLOGGERZcritical_initializer_failed
get_nowaitqueueEmpty_idle_semaphorereleaseZgetr%   r   r   r#   )Zexecutor_referencer4   Z
work_queueZexecutor	work_items   &&&  r
   _workerr=   a   sa   #7&113	 $c")+H
 yH,0B0B0B ')-H&t$
 		 K  9DI%'((* ;; 7-/',,446&NNN6	78  D3dCD 	sj   B D: C& *D: D: &D: D: AC#"C#&AD73D: 6D77D: :,E)&E> (E))E> >Fc                   s    ] tR t^tRtRtR# )BrokenThreadPoolzJ
Raised when a worker thread in a ThreadPoolExecutor failed initializing.
r   N)r&   r'   r(   r)   __doc__r+   r   r   r
   r>   r>      s    r   r>   c                   s,  a  ] tR t^t o ]t]P                  ! 4       P                  t	]
R 4       tRR ltR t]P                  P                  P                   ]n        R tR tRRR/R	 llt]P                  P&                  P                   ]n        R
tV tR# )ThreadPoolExecutorc                s,    \         P                  W4      # r   )r   r   )r   r   r   r   r
   prepare_contextZ"ThreadPoolExecutor.prepare_context   s    $$[;;r   Nc                s   Vf1   \        ^ \        P                  ! 4       ;'       g    ^^,           4      pV^ 8:  d   \        R4      h\	        V 4      P
                  ! W43/ VB w  V n        V n        Wn        \        P                  ! 4       V n        \        P                  ! ^ 4      V n        \        4       V n        RV n        RV n        \        P&                  ! 4       V n        T;'       g    RV P+                  4       ,          V n        R# )a  Initializes a new ThreadPoolExecutor instance.

Args:
    max_workers: The maximum number of threads that can be used to
        execute the given calls.
    thread_name_prefix: An optional name prefix to give our threads.
    initializer: A callable used to initialize worker threads.
    initargs: A tuple of arguments to pass to the initializer.
    ctxkwargs: Additional arguments to cls.prepare_context().
Nz"max_workers must be greater than 0FzThreadPoolExecutor-%d)ZminosZprocess_cpu_countZ
ValueErrorZtyperA   _create_worker_context_resolve_work_item_task_max_workersr8   ZSimpleQueue_work_queue	threadingZ	Semaphorer:   Zset_threads_brokenr   Lock_shutdown_lock_counter_thread_name_prefix)r   Zmax_workersZthread_name_prefixr   r   Z	ctxkwargss   &&&&&,r
   r   ZThreadPoolExecutor.__init__   s      b2#7#7#9#>#>Q!"CDK!ABB $Z''KK		$		% ( ,,.(2215'nn.$6 %P %P%<t}}%N 	 r   c          	     sT   V P                   ;_uu_ 4        \        ;_uu_ 4        V P                  '       d   V P                  V P                  4      hV P                  '       d   \        R 4      h\        '       d   \        R4      h\        P                  ! 4       pV P                  WV4      p\        WE4      pV P                  P                  V4       V P                  4        VuuRRR4       uuRRR4       #   + '       g   i     M; iRRR4       R#   + '       g   i     R# ; i)z*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdownN)rK   r   rI   BROKENr   ZRuntimeErrorr    ZFuturerD   r/   rF   r   _adjust_thread_count)r   r   r   r   Zfr$   Zws   ""*,   r
   submitZThreadPoolExecutor.submit   s       "7"7|||kk$,,//~~~"#OPPy" $: ; ; A//&AD!"A  #%%'! #8"7  "7"7    s/   D?C9	$C9	;A)C9	$
D9D	DD'	c                s   V P                   P                  ^ R7      '       d   R# V P                  3R lp\        V P                  4      pW P
                  8  d   RV P                  ;'       g    T V3,          p\        P                  ! V\        \        P                  ! W4      V P                  4       V P                  3R7      pVP                  4        V P                  P                  V4       V P                  \        V&   R# R# )i    )ZtimeoutNc                 s(    VP                  R 4       R # r   )r   )Z_r	   s   &&r
   
weakref_cbZ;ThreadPoolExecutor._adjust_thread_count.<locals>.weakref_cb   s    EE$Kr   z%s_%d)ZnameZtargetr   )r:   acquirerF   ZlenrH   rE   rM   rG   ZThreadr=   weakrefZrefrC   ZstartZaddr   )r   rQ   Znum_threadsZthread_namer   s   &    r
   rO   Z'ThreadPoolExecutor._adjust_thread_count   s    '''22 !,, 	 $--(***!T%=%=%E%E%0%2 2K  k''.{{4'D'+'B'B'D'+'7'7'9:A GGIMMa !%!1!1OA +r   c                s\   V P                   ;_uu_ 4        R V n          V P                  P                  4       pTf   K"  TP                  P                  T P                  T P                  4      4       KX    \        P
                   d     Mi ; iRRR4       R#   + '       g   i     R# ; i)zBA thread initializer failed, the thread pool is not usable anymoreN)	rK   rI   rF   r7   r8   r9   r1   r3   rN   )r   r<   s   & r
   r6   Z&ThreadPoolExecutor._initializer_failed   s       4DL  $ 0 0 ; ; =I ($$224;;t||3LM {{  !   s2   	BA5B6B5B
BBBB+	cancel_futuresFc               s   V P                   ;_uu_ 4        R V n        V'       d?     V P                  P                  4       pTf   K"  TP                  P                  4        K>  V P                  P                  R4       RRR4       V'       d&   V P                   F  pVP                  4        K  	  R# R#   \        P
                   d     Kj  i ; i  + '       g   i     L[; ir   )rK   r   rF   r7   r8   r9   r1   Zcancelr   rH   r   )r   ZwaitrT   r<   r   s   &&$  r
   shutdownZThreadPoolExecutor.shutdown   s       !DN $($4$4$?$?$A	 !,!((//1   & !  ]] #  !;;  ! s4   CB5C7C5C
CCCC!	)
rI   rC   r:   rE   rD   r   rK   rM   rH   rF   )NZ Nr   )T)r&   r'   r(   r)   r>   rN   	itertoolsZcountZ__next__rL   r*   rA   r   rP   r    Executorr?   rO   r6   rU   r+   r,   r-   r.   r
   r@   r@      s     F  ))H< <$QL$ ^^**22FN2,NE ( ~~..66Hr   r@   )r?   Z
__author__Zconcurrent.futuresr    rV   r8   rG   r5   rS   rB   ZWeakKeyDictionaryr   r   rJ   r   r   Z_register_atexitZhasattrr   rR   Z_at_fork_reinitr;   Zclearr   r/   r=   ZBrokenExecutorr>   rW   r@   r   r   r
   <module>rX      s    %1
 $      	 ++-	 "(  
  < ( 2!""4<<'<'L'L(=(E(EG '<'<=# #:8 8*,^u++ |7 |7r   