+
     Bi                         R R.t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^RI
Ht ^RI
HtHt ^RIHt RtRtRtR	t]P(                  ! 4       tR
 tR t ! R R]4      t ! R R4      tR t ! R R]4      tR!R ltR t ! R R]4      t  ! R R ]!4      t" ! R R]!4      t#]#t$ ! R R]#4      t% ! R R]!4      t& ! R R]&4      t' ! R  R]"4      t(R# )"Pool
ThreadPoolN)util)get_contextTimeoutError)waitINITRUNCLOSE	TERMINATEc                 &    \        \        V !  4      # N)listmapargss   &+/usr/lib/python3.14/multiprocessing/pool.pymapstarr   /   s    T
    c                 ^    \        \        P                  ! V ^ ,          V ^,          4      4      # )    )r   	itertoolsstarmapr   s   &r   starmapstarr   2   s"    	!!$q'47344r   c                   ,   a  ] tR t^9t o R tR tRtV tR# )RemoteTracebackc                    Wn         R # r   tb)selfr   s   &&r   __init__RemoteTraceback.__init__:   s    r   c                    V P                   # r   r   r   s   &r   __str__RemoteTraceback.__str__<   s    wwr   r   N)__name__
__module____qualname____firstlineno__r    r$   __static_attributes____classdictcell____classdict__s   @r   r   r   9   s      r   r   c                   ,   a  ] tR t^?t o R tR tRtV tR# )ExceptionWithTracebackc                    \         P                  ! \        V4      W4      pR P                  V4      pWn        RV,          V n        R# ) z

"""
%s"""N)	tracebackformat_exceptiontypejoinexcr   )r   r6   r   s   &&&r   r    ExceptionWithTraceback.__init__@   s6    ''S	3;WWR[ 2%r   c                >    \         V P                  V P                  33# r   )rebuild_excr6   r   r#   s   &r   
__reduce__!ExceptionWithTraceback.__reduce__E   s    TXXtww///r   r6   r   N)r&   r'   r(   r)   r    r:   r*   r+   r,   s   @r   r/   r/   ?   s     &
0 0r   r/   c                 &    \        V4      V n        V # r   )r   	__cause__r<   s   &&r   r9   r9   H   s    #B'CMJr   c                   B   a a ] tR t^Pt oRtV 3R ltR tR tRtVt	V ;t
# )MaybeEncodingErrorzRWraps possible unpickleable errors, so they can be
safely sent through the socket.c                   < \        V4      V n        \        V4      V n        \        \        V `  V P                  V P                  4       R # r   )reprr6   valuesuperr@   r    )r   r6   rC   	__class__s   &&&r   r    MaybeEncodingError.__init__T   s3    9%[
 $04::Fr   c                @    R V P                   : RV P                  : R2# )zError sending result: 'z'. Reason: '')rC   r6   r#   s   &r   r$   MaybeEncodingError.__str__Y   s    =AZZ=AXXG 	Gr   c                @    R V P                   P                  : RV : R2# )<z: >)rE   r&   r#   s   &r   __repr__MaybeEncodingError.__repr__]   s    !^^44d;;r   )r6   rC   )r&   r'   r(   r)   __doc__r    r$   rM   r*   r+   __classcell__rE   r-   s   @@r   r@   r@   P   s      'G
G< <r   r@   c                    Ve8   \        V\        4      '       d   V^8  g   \        RP                  V4      4      hVP                  pV P
                  p\        V R4      '       d5   V P                  P                  4        VP                  P                  4        Ve   V! V!   ^ pVe   V'       d\   W8  dV    V! 4       p	T	f   \        P                  ! R4       M2T	w  rrp RT! T/ TB 3p T! YT34       R ;p	;p
;p;p;rT^,          pKg  \        P                  ! RV,          4       R #   \        \        3 d    \        P                  ! R4        KI  i ; i  \         d7   pT'       d!   T\        Jd   \!        TTP"                  4      pRT3p R p?LR p?ii ; i  \         dG   p\%        TT^,          4      p\        P                  ! RT,          4       T! YRT334        R p?LR p?ii ; i)	NzMaxtasks {!r} is not valid_writerz)worker got EOFError or OSError -- exitingzworker got sentinel -- exitingTFz0Possible encoding error while sending result: %szworker exiting after %d tasks)
isinstanceintAssertionErrorformatputgethasattrrS   close_readerEOFErrorOSErrorr   debug	Exception_helper_reraises_exceptionr/   __traceback__r@   )inqueueoutqueueinitializerinitargsmaxtaskswrap_exceptionrX   rY   	completedtaskjobifuncr   kwdsresultewrappeds   &&&&&&            r   workerrr   a   s   z(C'@'@+3q=9@@JKK
,,C
++Cw	"" XI

xI,@	5D
 <JJ78#' D	 D$/$/0F
	, ! 4877s7V7d7TQ	JJ.:;3 '" 	JJBC	  	 $.H"H*1aoo>QZF	   	,(F1I6GJJI %)*++		,sB   9D, "
E -
F ,'EEF%,FFG/)<G**G/c                    V h)z@Pickle-able helper function for use by _guarded_task_generation. )exs   &r   ra   ra      s    
Hr   c                   J   a a ] tR t^t oRtRR/V 3R lltV 3R ltRtVtV ;t	# )
_PoolCachez
Class that implements a cache for the Pool class that will notify
the pool management threads every time the cache is emptied. The
notification is done by the use of a queue that is provided when
instantiating the cache.
notifierNc              4   < Wn         \        SV `  ! V/ VB  R # r   )rx   rD   r    )r   rx   r   rn   rE   s   "$*,r   r    _PoolCache.__init__   s     $'$'r   c                p   < \         SV `  V4       V '       g   V P                  P                  R 4       R # R # r   )rD   __delitem__rx   rX   )r   itemrE   s   &&r   r|   _PoolCache.__delitem__   s,    D! MMd# r   rx   )
r&   r'   r(   r)   rO   r    r|   r*   r+   rP   rQ   s   @@r   rw   rw      s      ($ (
$ 
$r   rw   c                     a  ] tR t^t o RtRt]R 4       tR)R lt]	P                  ]3R ltR tR t]R	 4       t]R
 4       tR t]R 4       t]R 4       tR tR tR(/ 3R ltR*R ltR*R ltR+R ltR tR,R ltR,R ltR(/ RR3R ltR+R ltR+R lt]R*R l4       t ]!R 4       t"]R 4       t#]R 4       t$]R 4       t%R t&R  t'R! t(R" t)]R# 4       t*]!R$ 4       t+R% t,R& t-R't.V t/R# )-r   zK
Class which supports an async version of applying functions to arguments.
Tc                &    V P                   ! V/ VB # r   Process)ctxr   rn   s   &*,r   r   Pool.Process   s    {{D)D))r   Nc                   . V n         \        V n        T;'       g    \        4       V n        V P                  4        \        P                  ! 4       V n        V P                  P                  4       V n	        \        V P                  R 7      V n        W@n        W n        W0n        Vf    \        P                   ! 4       ;'       g    ^pV^8  d   \#        R4      hVe)   \%        V\&        4      '       d   V^ 8:  d   \#        R4      hVe   \)        V4      '       g   \+        R4      hWn         V P/                  4        T P9                  4       p\:        P<                  ! \>        P@                  T P                  T P                  T P                  T PB                  T P,                  T P                   T PD                  T PF                  T P                  T P                  T P                  T PH                  YpP                  3R7      T n%        RT PJ                  n&        \N        T PJ                  n        T PJ                  PQ                  4        \:        P<                  ! \>        PR                  T P                  T PT                  T PF                  T P                   T P                  3R7      T n+        RT PV                  n&        \N        T PV                  n        T PV                  PQ                  4        \:        P<                  ! \>        PX                  T PF                  T PZ                  T P                  3R7      T n.        RT P\                  n&        \N        T P\                  n        T P\                  PQ                  4        \^        P`                  ! Y Pb                  T P                  T PD                  T PF                  T P                   T P                  T PJ                  T PV                  T P\                  T P                  3	^R7      T n2        \N        T n        R#   \0         dY    T P                    F#  pTP2                  e   K  TP5                  4        K%  	  T P                    F  pTP7                  4        K  	  h i ; i)r   Nz&Number of processes must be at least 1z/maxtasksperchild must be a positive int or Nonezinitializer must be a callabletargetr   T)r   exitpriority)3_poolr   _stater   _ctx_setup_queuesqueueSimpleQueue
_taskqueue_change_notifierrw   _cache_maxtasksperchild_initializer	_initargsosprocess_cpu_count
ValueErrorrT   rU   callable	TypeError
_processes_repopulate_poolr`   exitcode	terminater5   _get_sentinels	threadingThreadr   _handle_workersr   _inqueue	_outqueue_wrap_exception_worker_handlerdaemonr	   start_handle_tasks
_quick_put_task_handler_handle_results
_quick_get_result_handlerr   Finalize_terminate_pool
_terminate)r   	processesre   rf   maxtasksperchildcontextp	sentinelss   &&&&&&  r   r    Pool.__init__   sO    
,,{}	++- !%		 5 5 7 $*?*?@!1'!,,.33!Iq=EFF'.448HA8M !RSS"8K+@+@<==#	!!# '')	(//''++t		4<<//4::t}}dnn##T^^T5K5K&&	3H3HJ  '+#&)#""$ '--%%//4??DNN**dkk+
 %)!$'!  "(//''..$//4;;?  '+#&)#""$--&&//4==$..$**'')=)=t?Q?Q&&5  ]  	ZZ::%KKM   ZZ  	s   *P
 
%Q-49Q-c                    V P                   V8X  dB   V! R V : 2\        V R7       \        V RR4      e   V P                  P	                  R4       R# R# R# )z&unclosed running multiprocessing pool )sourcer   N)r   ResourceWarninggetattrr   rX   )r   _warnr	   s   &&&r   __del__Pool.__del__
  sT    ;;#:4(C!$0t/6B%%))$/ C r   c           
         V P                   pR VP                   RVP                   RV P                   R\	        V P
                  4       R2	# )rK   .z state=z pool_size=rL   )rE   r'   r(   r   lenr   )r   clss   & r   rM   Pool.__repr__  sQ    nnCNN#1S%5%5$6 7 & _-Q0 	1r   c                j    V P                   P                  .pV P                  P                  .p. VOVO# r   )r   r\   r   )r   task_queue_sentinelsself_notifier_sentinelss   &  r   r   Pool._get_sentinels  s<     $ 6 67#'#8#8#@#@"A@%@(?@@r   c                l    V  Uu. uF#  p\        VR 4      '       g   K  VP                  NK%  	  up# u upi )sentinel)rZ   r   )workersrr   s   & r   _get_worker_sentinelsPool._get_worker_sentinels  s<     8 %+"6:6  8 	8 8s   11c                    Rp\        \        \        V 4      4      4       FL  pW,          pVP                  f   K  \        P
                  ! RV,          4       VP                  4        RpW KN  	  V# )zCleanup after any worker processes which have exited due to reaching
their specified lifetime.  Returns True if any workers were cleaned up.
Fcleaning up worker %dT)reversedranger   r   r   r_   r5   )poolcleanedrl   rr   s   &   r   _join_exited_workersPool._join_exited_workers!  s^    
 %D	*+AWF*

2Q67G , r   c                    V P                  V P                  V P                  V P                  V P                  V P
                  V P                  V P                  V P                  V P                  V P                  4
      # r   )_repopulate_pool_staticr   r   r   r   r   r   r   r   r   r   r#   s   &r   r   Pool._repopulate_pool1  s_    ++DIIt||,0OO,0JJ,0NND<M<M,0NN,0,B,B,0,@,@B 	Br   c
                .   \        V\        V4      ,
          4       Fu  p
V! V \        WEVWxV	3R7      pVP                  P	                  RR4      Vn        RVn        VP                  4        VP                  V4       \        P                  ! R4       Kw  	  R# )zpBring the number of pool processes up to the specified number,
for use after reaping workers which have exited.
r   r   
PoolWorkerTzadded workerN)
r   r   rr   namereplacer   r   appendr   r_   )r   r   r   r   rc   rd   re   rf   r   rh   rl   ws   &&&&&&&&&&  r   r   Pool._repopulate_pool_static:  sz     y3t9,-AF%)&,./A
 VV^^I|<AFAHGGIKKNJJ~& .r   c
                t    \         P                  V4      '       d   \         P                  WW#WEVWxV	4
       R# R# )zEClean up any exited workers and start replacements for them.
        N)r   r   r   )
r   r   r   r   rc   rd   re   rf   r   rh   s
   &&&&&&&&&&r   _maintain_poolPool._maintain_poolM  s7     $$T**((y)0K)1)79 +r   c                   V P                   P                  4       V n        V P                   P                  4       V n        V P                  P                  P
                  V n        V P                  P                  P                  V n	        R # r   )
r   r   r   r   rS   sendr   r\   recvr   r#   s   &r   r   Pool._setup_queuesY  sX    		--/..0--//44..0055r   c                F    V P                   \        8w  d   \        R 4      hR# )zPool not runningN)r   r	   r   r#   s   &r   _check_runningPool._check_running_  s    ;;#/00 r   c                B    V P                  WV4      P                  4       # )z<
Equivalent of `func(*args, **kwds)`.
Pool must be running.
)apply_asyncrY   )r   rm   r   rn   s   &&&&r   apply
Pool.applyc  s     
 D15577r   c                L    V P                  W\        V4      P                  4       # )z`
Apply `func` to each element in `iterable`, collecting the results
in a list that is returned.
)
_map_asyncr   rY   r   rm   iterable	chunksizes   &&&&r   r   Pool.mapj  s     
 tw	BFFHHr   c                L    V P                  W\        V4      P                  4       # )z
Like `map()` method but the elements of the `iterable` are expected to
be iterables as well and will be unpacked as arguments. Hence
`func` and (a, b) becomes func(a, b).
)r   r   rY   r   s   &&&&r   r   Pool.starmapq  s      t{IFJJLLr   c                2    V P                  W\        VWE4      # )z-
Asynchronous version of `starmap()` method.
)r   r   r   rm   r   r   callbackerror_callbacks   &&&&&&r   starmap_asyncPool.starmap_asyncy  s    
 t{I'9 	9r   c              #     "    Rp\        V4       F  w  rEWW%3/ 3x  K  	  R#   \         d!   pTX^,           \        T3/ 3x   Rp?R# Rp?ii ; i5i)zProvides a generator of tasks for imap and imap_unordered with
appropriate handling for iterables which throw exceptions during
iteration.N)	enumerater`   ra   )r   
result_jobrm   r   rl   xrp   s   &&&&   r   _guarded_task_generationPool._guarded_task_generation  s\     	JA!(+!dD"55 , 	Jqs$>bIII	Js*   A$ AAA
A
AAc                   V P                  4        V^8X  dO   \        V 4      pV P                  P                  V P	                  VP
                  W4      VP                  34       V# V^8  d   \        RP                  V4      4      h\        P                  WV4      p\        V 4      pV P                  P                  V P	                  VP
                  \        V4      VP                  34       R V 4       # )z@
Equivalent of `map()` -- can be MUCH slower than `Pool.map()`.
zChunksize must be 1+, not {0:n}c              3   4   "   T F  q F  q"x  K  	  K  	  R # 5ir   rt   .0chunkr}   s   &  r   	<genexpr>Pool.imap.<locals>.<genexpr>       ?fUDDf   )r   IMapIteratorr   rX   r   _job_set_lengthr   rW   r   
_get_tasksr   r   rm   r   r   ro   task_batchess   &&&&  r   imap	Pool.imap  s     	>!$'FOO11&++tN&&
 M1} 5<<!#$ $  ??49EL!$'FOO11&++292>@ &&	 @f??r   c                   V P                  4        V^8X  dO   \        V 4      pV P                  P                  V P	                  VP
                  W4      VP                  34       V# V^8  d   \        RP                  V4      4      h\        P                  WV4      p\        V 4      pV P                  P                  V P	                  VP
                  \        V4      VP                  34       R V 4       # )z<
Like `imap()` method but ordering of results is arbitrary.
zChunksize must be 1+, not {0!r}c              3   4   "   T F  q F  q"x  K  	  K  	  R # 5ir   rt   r  s   &  r   r  &Pool.imap_unordered.<locals>.<genexpr>  r	  r
  )r   IMapUnorderedIteratorr   rX   r   r  r  r   rW   r   r  r   r  s   &&&&  r   imap_unorderedPool.imap_unordered  s     	>*40FOO11&++tN&&
 M1} 5<<YGI I??49EL*40FOO11&++292>@ &&	 @f??r   c                    V P                  4        \        WV4      pV P                  P                  VP                  ^ WV3.R34       V# )z+
Asynchronous version of `apply()` method.
N)r   ApplyResultr   rX   r  )r   rm   r   rn   r   r   ro   s   &&&&&& r   r   Pool.apply_async  sH    
 	T^<v{{At4@A4HIr   c                2    V P                  W\        W4V4      # )z)
Asynchronous version of `map()` method.
)r   r   r   s   &&&&&&r   	map_asyncPool.map_async  s    
 tw	 	r   c                   V P                  4        \        VR4      '       g   \        V4      pVfC   \        \	        V4      \	        V P
                  4      ^,          4      w  rGV'       d
   V^,          p\	        V4      ^ 8X  d   ^ p\        P                  WV4      p\        W\	        V4      VVR7      p	V P                  P                  V P                  V	P                  VV4      R34       V	# )zI
Helper function to implement map, starmap and their async counterparts.
__len__Nr   )r   rZ   r   divmodr   r   r   r  	MapResultr   rX   r   r  )
r   rm   r   mapperr   r   r   extrar  ro   s
   &&&&&&&   r   r   Pool._map_async  s    
 	x++H~H%c(mS_q5HIIQ	x=AItyA4CM8*8:--fkk.4.:< 		
 r   c                n    \        WR 7       VP                  4       '       g   VP                  4        K(  R# ))timeoutN)r   emptyrY   )r   change_notifierr(  s   &&&r   _wait_for_updatesPool._wait_for_updates  s*    Y(!''))! *r   c                `   \         P                  ! 4       pVP                  \        8X  g   V'       dU   VP                  \        8w  d@   V P                  W4WVVWV
W4
       . V P                  V4      OVOpV P                  VV4       Kq  VP                  R 4       \        P                  ! R4       R # )Nzworker handler exiting)r   current_threadr   r	   r   r   r   r+  rX   r   r_   )r   cache	taskqueuer   r   r   r   rc   rd   re   rf   r   rh   r   r*  threadcurrent_sentinelss   &&&&&&&&&&&&&&&  r   r   Pool._handle_workers  s    
 ))+ mms"u)1KsYg'h/A !O#";";D"A NI N!!"3_Ed

+,r   c                   \         P                  ! 4       p\        V P                  R 4       F  w  rgR p V F9  pVP                  \
        8w  d   \        P                  ! R4        MU V! V4       K;  	  V'       d9   \        P                  ! R4       V'       d
   V^,          MR
pV! V^,           4        R ;p;rjK   R ;p;rj M	  \        P                  ! R4        \        P                  ! R4       VP                  R 4       \        P                  ! R4       V F  pV! R 4       K  	  \        P                  ! R	4       R #   \         dJ   p	TR,          w  r YJ,          P                  TRT	34        R p	?	EKD    \         d
      R p	?	EKW  i ; iR p	?	ii ; i  R ;p;rji ; i  \         d    \        P                  ! R4        Li ; i)Nz'task handler found thread._state != RUN:N   NFzdoing set_length()ztask handler got sentinelz/task handler sending sentinel to result handlerz(task handler sending sentinel to workersz/task handler got OSError when sending sentinelsztask handler exitingr   )r   r.  iterrY   r   r	   r   r_   r`   _setKeyErrorrX   r^   )r0  rX   rd   r   r/  r1  taskseq
set_lengthrj   rp   rk   idxr   s   &&&&&        r   r   Pool._handle_tasks  s   ))+#'	t#<GD,#D}}+

#LM!D	 $ "

#78)-d1g2"37+ (,++w '+++w1 $=4 JJ23
	JJJHILL JJABD	 
 	

)*= % !#'8!!JOOC%<<' ! !	! (,++w  	JJJHI	Jsx   2F'E/F;FFAF# FFE:3F:F	FFF	FFFF #!GGc                h   \         P                  ! 4       p  V! 4       pTP                  \        8w  d4   TP                  \        8X  g   Q R4       h\        P
                  ! R4       M?Tf   \        P
                  ! R4       M$Tw  rVp Y%,          P                  Yg4       R;p;rWK  T'       d^   TP                  \        8w  dI    T! 4       pTf   \        P
                  ! R4       KA  Tw  rVp Y%,          P                  Yg4       R;p;rWKe  \        T R4      '       dT   \        P
                  ! R4        \        ^
4       F,  pT P                  P                  4       '       g    MT! 4        K.  	   \        P
                  ! R	\        T4      TP                  4       R#   \        \        3 d    \        P
                  ! R4        R# i ; i  \         d     EL:i ; i  \        \        3 d    \        P
                  ! R4        R# i ; i  \         d     ELi ; i  \        \        3 d     Li ; i)
   z.result handler got EOFError/OSError -- exitingNzThread not in TERMINATEz,result handler found thread._state=TERMINATEzresult handler got sentinelz&result handler ignoring extra sentinelr\   z"ensuring that outqueue is not fullz7result handler exiting: len(cache)=%s, thread._state=%s)r   r.  r^   r]   r   r_   r   r	   r   r7  r8  rZ   r   r\   pollr   )rd   rY   r/  r1  rj   rk   rl   objs   &&&     r   r   Pool._handle_results=  s   ))+u
 }}#}}	1L3LL1

IJ|

89KCC
'  $#D#32u
 |

CDKCC
'  $#D#38Y''JJ;<rA#++0022E # 	

L%j&--	)e X& 

KL    X& 

KL   X& s_   F G G -H 4/H $H 'GGGG'HHHHH10H1c              #     "   \        V4      p \        \        P                  ! W4      4      pV'       g   R# W3x  K1  5ir>  N)r6  tupler   islice)rm   itsizer   s   &&& r   r  Pool._get_tasksy  s3     "Xi&&r01A)Os   =?c                    \        R 4      h)z:pool objects cannot be passed between processes or pickled)NotImplementedErrorr#   s   &r   r:   Pool.__reduce__  s    !J 	r   c                    \         P                  ! R 4       V P                  \        8X  d>   \        V n        \        V P
                  n        V P                  P                  R4       R# R# )zclosing poolN)r   r_   r   r	   r
   r   r   rX   r#   s   &r   r[   
Pool.close  sH    

>";;#DK*/D  '!!%%d+ r   c                h    \         P                  ! R 4       \        V n        V P	                  4        R# )zterminating poolN)r   r_   r   r   r   r#   s   &r   r   Pool.terminate  s     

%&r   c                   \         P                  ! R 4       V P                  \        8X  d   \	        R4      hV P                  \
        \        39  d   \	        R4      hV P                  P                  4        V P                  P                  4        V P                  P                  4        V P                   F  pVP                  4        K  	  R# )zjoining poolzPool is still runningzIn unknown stateN)r   r_   r   r	   r   r
   r   r   r5   r   r   r   )r   r   s   & r   r5   	Pool.join  s    

>";;#455[[	 22/00!!#!!!#AFFH r   c                :   \         P                  ! R 4       V P                  P                  4        VP	                  4       '       dU   V P
                  P                  4       '       d3   V P
                  P                  4        \        P                  ! ^ 4       Kh  R# R# )z7removing tasks from inqueue until task handler finishedN)
r   r_   _rlockacquireis_aliver\   r?  r   timesleep)rc   task_handlerrG  s   &&&r   _help_stuff_finishPool._help_stuff_finish  sf     	

LM ##%%'//*>*>*@*@OO  "JJqM +A%r   c
                   \         P                  ! R 4       \        Vn        VP	                  R4       \        Vn        \         P                  ! R4       V P                  W'\        V4      4       VP                  4       '       g   \        V	4      ^ 8w  d   \        R4      h\        Vn        VP	                  R4       VP	                  R4       \         P                  ! R4       \        P                  ! 4       VJd   VP                  4        V'       dY   \        V^ ,          R4      '       d@   \         P                  ! R4       V F#  p
V
P                  e   K  V
P                  4        K%  	  \         P                  ! R4       \        P                  ! 4       VJd   VP                  4        \         P                  ! R4       \        P                  ! 4       VJd   VP                  4        V'       d   \        V^ ,          R4      '       dq   \         P                  ! R	4       V FR  p
V
P                  4       '       g   K  \         P                  ! R
V
P                  ,          4       V
P                  4        KT  	  R# R# R# )zfinalizing poolNz&helping task handler/workers to finishz/Cannot have cache with result_handler not alivezjoining worker handlerr   zterminating workerszjoining task handlerzjoining result handlerzjoining pool workersr   )r   r_   r   r   rX   rY  r   rU  rV   r   r.  r5   rZ   r   r   pid)r   r0  rc   rd   r   r*  worker_handlerrX  result_handlerr/  r   s   &&&&&&&&&& r   r   Pool._terminate_pool  s    	

$%
 !*D!'

;<wc$i@''))E
a AC C !*D!T 	

+,##%^;! GDG[11JJ,-::%KKM  	

)*##%\9

+,##%^;!GDG[11JJ-.::<<JJ6>?FFH	  24r   c                &    V P                  4        V # r   )r   r#   s   &r   	__enter__Pool.__enter__  s    r   c                &    V P                  4        R # r   )r   )r   exc_typeexc_valexc_tbs   &&&&r   __exit__Pool.__exit__  s    r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rt   )NNrt   NNr   )NNN)r>  )0r&   r'   r(   r)   rO   r   staticmethodr   r    warningswarnr	   r   rM   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r  r   r+  classmethodr   r   r   r  r:   r[   r   r5   rY  r   ra  rg  r*   r+   r,   s   @r   r   r      s     O* *Of %MMs 01A
 8 8  B ' '$ 	9 	961  " 8IM9	J@:@8 &(b4: " "
 - -( ++ ++Z 9) 9)v  
,

   3 3j r   c                   p   a  ] tR tRt o R tR tR tR
R ltR
R ltR t	]
! ]P                  4      tR	tV tR# )r  i  c                    Wn         \        P                  ! 4       V n        \	        \
        4      V n        VP                  V n        W n        W0n	        W P                  V P                  &   R # r   )
r   r   Event_eventnextjob_counterr  r   	_callback_error_callback)r   r   r   r   s   &&&&r   r    ApplyResult.__init__  sG    
oo'%	kk!-!%DIIr   c                6    V P                   P                  4       # r   )rp  is_setr#   s   &r   readyApplyResult.ready  s    {{!!##r   c                z    V P                  4       '       g   \        R P                  V 4      4      hV P                  # )z{0!r} not ready)rx  r   rW   _successr#   s   &r   
successfulApplyResult.successful  s.    zz||.55d;<<}}r   Nc                <    V P                   P                  V4       R # r   )rp  r   r   r(  s   &&r   r   ApplyResult.wait  s    !r   c                    V P                  V4       V P                  4       '       g   \        hV P                  '       d   V P                  # V P                  hr   )r   rx  r   r{  _valuer  s   &&r   rY   ApplyResult.get  s<    		'zz||===;;++r   c                   Vw  V n         V n        V P                  '       d.   V P                   '       d   V P                  V P                  4       V P                  '       d.   V P                   '       g   V P                  V P                  4       V P                  P                  4        V P                  V P                   R V n        R # r   )	r{  r  rs  rt  rp  setr   r  r   r   rl   r@  s   &&&r   r7  ApplyResult._set  s|    %("t{>>>dmmmNN4;;'  -KK		"
r   )r   rs  rt  rp  r  r   r{  r  r   )r&   r'   r(   r)   r    rx  r|  r   rY   r7  rl  typesGenericAlias__class_getitem__r*   r+   r,   s   @r   r  r    s6     &$
" $E$6$67r   r  c                   ,   a  ] tR tRt o R tR tRtV tR# )r#  i  c                6   \         P                  WVVR 7       RV n        R.V,          V n        W n        V^ 8:  d;   ^ V n        V P                  P                  4        V P                  V P                   R# W2,          \        W2,          4      ,           V n        R# )r!  TN)r  r    r{  r  
_chunksize_number_leftrp  r  r   r  bool)r   r   r   lengthr   r   s   &&&&&&r   r    MapResult.__init__  sz    T,: 	 	<fvo#> !DKKOODII& & 1D9K4L LDr   c                   V ;P                   ^,          un         Vw  r4V'       d   V P                  '       d   W@P                  WP                  ,          V^,           V P                  ,          % V P                   ^ 8X  dh   V P                  '       d   V P	                  V P                  4       V P
                  V P                   V P                  P                  4        RV n	        R# R# V'       g    V P                  '       d   RV n        W@n        V P                   ^ 8X  dh   V P                  '       d   V P                  V P                  4       V P
                  V P                   V P                  P                  4        RV n	        R# R# )r>  NF)r  r{  r  r  rs  r   r  rp  r  r   rt  )r   rl   success_resultsuccessro   s   &&&  r   r7  MapResult._set)  s   Q(t}}}CIKK//)1Q3*?@  A%>>>NN4;;/KK		*!!
 & t}}} %$  A%'''((5KK		*!!
 &r   )r  r  r   r{  r  N)r&   r'   r(   r)   r    r7  r*   r+   r,   s   @r   r#  r#    s     M" "r   r#  c                   F   a  ] tR tRt o R tR tR	R lt]tR tR t	Rt
V tR# )
r  iE  c                F   Wn         \        P                  ! \        P                  ! 4       4      V n        \        \        4      V n        VP                  V n        \        P                  ! 4       V n        ^ V n        RV n        / V n        W P                  V P                  &   R# )r   N)r   r   	ConditionLock_condrq  rr  r  r   collectionsdeque_items_index_length	_unsorted)r   r   s   &&r   r    IMapIterator.__init__G  sl    
(()9:
%	kk!'')!%DIIr   c                    V # r   rt   r#   s   &r   __iter__IMapIterator.__iter__R  s    r   Nc                   V P                   ;_uu_ 4         V P                  P                  4       pR R R 4       Xw  r4T'       d   T# Th  \         d    T P                  T P
                  8X  d   R T n        \        R hT P                   P                  T4        T P                  P                  4       p L  \         d2    T P                  T P
                  8X  d   R T n        \        R h\        R hi ; ii ; i  + '       g   i     L; ir   )
r  r  popleft
IndexErrorr  r  r   StopIterationr   r   )r   r(  r}   r  rC   s   &&   r   rq  IMapIterator.nextU  s    ZZZ1{{**,   L!  1;;$,,.!%DJ'T1

(1;;..0D! 1{{dll2%)
+5&D0	11 Zs5   C8A		AC5B53C85<C1	1C55C88D	c                   V P                   ;_uu_ 4        V P                  V8X  d   V P                  P                  V4       V ;P                  ^,          un        V P                  V P                  9   d\   V P                  P                  V P                  4      pV P                  P                  V4       V ;P                  ^,          un        Kv  V P                   P                  4        MW P                  V&   V P                  V P                  8X  d   V P                  V P                   RV n
        RRR4       R#   + '       g   i     R# ; irC  )r  r  r  r   r  popnotifyr  r   r  r   r  s   &&&r   r7  IMapIterator._setm  s    ZZZ{{a""3'q kkT^^3..,,T[[9CKK&&s+KK1$K

!!#$'q!{{dll*KK		*!
 ZZZs   DD==E	c                   V P                   ;_uu_ 4        Wn        V P                  V P                  8X  d9   V P                   P                  4        V P                  V P
                   R V n        R R R 4       R #   + '       g   i     R # ; ir   )r  r  r  r  r   r  r   )r   r  s   &&r   r  IMapIterator._set_length~  sS    ZZZ!L{{dll*

!!#KK		*!
 ZZZs   AA99B
	)r   r  r  r  r  r  r   r  r   )r&   r'   r(   r)   r    r  rq  __next__r7  r  r*   r+   r,   s   @r   r  r  E  s*     	&, H""" "r   r  c                   &   a  ] tR tRt o R tRtV tR# )r  i  c                v   V P                   ;_uu_ 4        V P                  P                  V4       V ;P                  ^,          un        V P                   P	                  4        V P                  V P
                  8X  d   V P                  V P                   RV n        RRR4       R#   + '       g   i     R# ; irC  )	r  r  r   r  r  r  r   r  r   r  s   &&&r   r7  IMapUnorderedIterator._set  sn    ZZZKKs#KK1KJJ{{dll*KK		*!
 ZZZs   BB''B8	)r   N)r&   r'   r(   r)   r7  r*   r+   r,   s   @r   r  r    s     " "r   r  c                   p   a  ] tR tRt o Rt]R 4       tRR ltR tR t	]R 4       t
]R	 4       tR
 tRtV tR# )r   i  Fc                    ^RI Hp V! V/ VB # )r>  r   )dummyr   )r   r   rn   r   s   &*, r   r   ThreadPool.Process  s    "%%%r   Nc                2    \         P                  WW#4       R # r   )r   r    )r   r   re   rf   s   &&&&r   r    ThreadPool.__init__  s    d{=r   c                    \         P                  ! 4       V n        \         P                  ! 4       V n        V P                  P                  V n        V P                  P                  V n        R # r   )r   r   r   r   rX   r   rY   r   r#   s   &r   r   ThreadPool._setup_queues  sD    ))+**,--++..,,r   c                0    V P                   P                  .# r   )r   r\   r#   s   &r   r   ThreadPool._get_sentinels  s    %%--..r   c                    . # r   rt   )r   s   &r   r    ThreadPool._get_worker_sentinels  s    	r   c                      V P                  RR7       K    \        P                   d     Mi ; i\        T4       F  pT P	                  R4       K  	  R# )TF)blockN)rY   r   Emptyr   rX   )rc   rX  rG  rl   s   &&& r   rY  ThreadPool._help_stuff_finish  sH    	%({{ 		tAKK s    //c                2    \         P                  ! V4       R # r   )rV  rW  )r   r   r*  r(  s   &&&&r   r+  ThreadPool._wait_for_updates  s    

7r   )r   r   r   r   )NNrt   )r&   r'   r(   r)   r   ri  r   r    r   r   r   rY  r+  r*   r+   r,   s   @r   r   r     s]     O& &>-/     r   )Nrt   NF))__all__r  r   r   r   r   rV  r2   r  rj  r1   r   r   r   
connectionr   r   r	   r
   r   countrr  r   r   r`   r   r/   r9   r@   rr   ra   dictrw   objectr   r  AsyncResultr#  r  r  r   rt   r   r   <module>r     s    <
    	        '  	 oo5i 0 0< <"+<Z$ $.v6 vx)8& )8V %" %"V?"6 ?"J	"L 	"$ $r   