Ë
    [^(h2  ã                   ó8  — d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZmZ d dlmZ ddlmZ dZ e j$                  e«      Zg d¢Z G d„ d	e«      Z G d
„ de«      Z G d„ de«      Zd„ Z G d„ d«      Z G d„ de«      Z	 	 	 	 	 dd„Zdd„Zy)é    N)Úas_completedÚThreadPoolExecutor)ÚOptionalé   )Ú_prctl_pr_set_pdeathsigÚTORCH_MP_PARALLEL_START)ÚProcessContextÚProcessExceptionÚProcessExitedExceptionÚProcessRaisedExceptionÚspawnÚSpawnContextÚstart_processesc                   ó:   ‡ — e Zd ZddgZdededefˆ fd„Zd„ Zˆ xZS )r
   Úerror_indexÚ	error_pidÚmsgÚpidc                 óN   •— t         ‰| �  |«       || _        || _        || _        y ©N)ÚsuperÚ__init__r   r   r   )Úselfr   r   r   Ú	__class__s       €úY/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/torch/multiprocessing/spawn.pyr   zProcessException.__init__$   s&   ø€ Ü‰Ñ˜ÔØˆŒØ&ˆÔØˆ�ó    c                 ó^   — t        | «      | j                  | j                  | j                  ffS r   )Útyper   r   r   ©r   s    r   Ú
__reduce__zProcessException.__reduce__*   s&   € Ü�D‹z˜DŸH™H d×&6Ñ&6¸¿¹ÐAÐAÐAr   )	Ú__name__Ú
__module__Ú__qualname__Ú	__slots__ÚstrÚintr   r    Ú__classcell__©r   s   @r   r
   r
   !   s-   ø„ Ø Ð,€Ið˜Cð ¨cð ¸õ öBr   r
   c                   ó0   ‡ — e Zd ZdZdededefˆ fd„Zˆ xZS )r   zNException raised when a process failed due to an exception raised by the code.r   r   r   c                 ó(   •— t         ‰| �  |||«       y r   )r   r   )r   r   r   r   r   s       €r   r   zProcessRaisedException.__init__1   s   ø€ ô 	‰Ñ˜˜k¨9Õ5r   )r!   r"   r#   Ú__doc__r%   r&   r   r'   r(   s   @r   r   r   .   s,   ø„ ÙXð6àð6ð ð6ð ÷	6ñ 6r   r   c                   óN   ‡ — e Zd ZdZdgZ	 d	dededededee   f
ˆ fd„Zd„ Z	ˆ xZ
S )
r   zTException raised when a process failed due to signal or exited with a specific code.Ú	exit_coder   r   r   Úsignal_namec                 óD   •— t         ‰| �  |||«       || _        || _        y r   )r   r   r-   r.   )r   r   r   r   r-   r.   r   s         €r   r   zProcessExitedException.__init__?   s%   ø€ ô 	‰Ñ˜˜k¨9Ô5Ø"ˆŒØ&ˆÕr   c                 óŠ   — t        | «      | j                  | j                  | j                  | j                  | j
                  ffS r   )r   r   r   r   r-   r.   r   s    r   r    z!ProcessExitedException.__reduce__K   s9   € ä�‹JØ�X‰X�t×'Ñ'¨¯©°4·>±>À4×CSÑCSÐTð
ð 	
r   r   )r!   r"   r#   r+   r$   r%   r&   r   r   r    r'   r(   s   @r   r   r   :   sP   ø„ Ù^à�€Ið &*ñ
'àð
'ð ð
'ð ð	
'ð
 ð
'ð ˜c‘]õ
'ö
r   r   c                 ó:  — t        t        j                  «       	  | |g|¢­Ž  y # t        $ r Y y t        $ rb dd l}t        |d«      5 }t        j                  |j                  «       |«       d d d «       n# 1 sw Y   nxY wt        j                  d«       Y y w xY w)Nr   Úwbr   )r   ÚsignalÚSIGINTÚKeyboardInterruptÚ	ExceptionÚ	tracebackÚopenÚpickleÚdumpÚ
format_excÚsysÚexit)ÚfnÚiÚargsÚ
error_filer7   Úfhs         r   Ú_wraprC   R   s€   € ô
 œFŸM™MÔ*ð
Ù
ˆ1ˆˆtŒøÜò ÙÜò ãä�*˜dÓ#ð 	4 rÜ�K‰K˜	×,Ñ,Ó.°Ô3÷	4÷ 	4ñ 	4úä�‰�Žðús,   ›	% ¥	B°BÁ%A6Á-	BÁ6A?	Á;BÂBc                   óD   — e Zd Zd„ Zd„ Zdefd„Z	 ddee   dee   fd„Zy)	r	   c                 óˆ   — || _         || _        t        |«      D ��ci c]  \  }}|j                  |“Œ c}}| _        y c c}}w r   )Úerror_filesÚ	processesÚ	enumerateÚsentinelÚ	sentinels)r   rG   rF   ÚindexÚprocesss        r   r   zProcessContext.__init__g   sA   € Ø&ˆÔØ"ˆŒä:CÀIÓ:N÷
Ù(6¨¨wˆG×Ñ˜eÑ#ó
ˆ�ùó 
s   �>c                 óf   — | j                   D �cg c]  }t        |j                  «      ‘Œ c}S c c}w r   )rG   r&   r   )r   rL   s     r   ÚpidszProcessContext.pidsn   s#   € Ø04·±Ö? W”�G—K‘KÕ Ò?Ð?ùÒ?s   �.Útimeoutc                 ó¸   — t        j                  «       |z   }| j                  D ]4  }t        d|t        j                  «       z
  «      }|j	                  |«       Œ6 y)z4Attempt to join all processes with a shared timeout.r   N)ÚtimeÚ	monotonicrG   ÚmaxÚjoin)r   rO   ÚendrL   Útime_to_waits        r   Ú_join_procs_with_timeoutz'ProcessContext._join_procs_with_timeoutq   sJ   € ä�n‰nÓ Ñ(ˆØ—~‘~ò 	'ˆGÜ˜q #¬¯©Ó(8Ñ"8Ó9ˆLØ�L‰L˜Õ&ñ	'r   NÚgrace_periodc                 ó¶  — t        | j                  «      dk(  ryt        j                  j	                  | j                  j                  «       |¬«      }d}|D ]O  }| j                  j                  |«      }| j                  |   }|j                  «        |j                  dk7  sŒM|} n |€t        | j                  «      dk(  S |�| j                  |«       | j                  D ]C  }|j                  «       sŒt        j                  d|j                  «       |j                  «        ŒE | j                  |€dn|«       | j                  D ]R  }|j                  «       r0t        j                  d|j                  «       |j!                  «        |j                  «        ŒT | j                  |   }t#        j$                  | j&                  |   t"        j(                  «      s�| j                  |   j                  }	|	dk  rB	 t+        j,                  |	 «      j.                  }
t3        d
|d›d|
› �||j                  |	|
¬«      ‚t3        d
|d›d|	d›�||j                  |	¬«      ‚t5        | j&                  |   d«      5 }t7        j8                  |«      }ddd«       d|d›d�}|z  }t;        |||j                  «      ‚# t0        $ r
 d|	 › d	�}
Y Œ®w xY w# 1 sw Y   ŒBxY w)aL  Join one or more processes within spawn context.

        Attempt to join one or more processes in this spawn context.
        If one of them exited with a non-zero exit status, this function
        kills the remaining processes (optionally with a grace period)
        and raises an exception with the cause of the first process exiting.

        Returns ``True`` if all processes have been joined successfully,
        ``False`` if there are more processes that need to be joined.

        Args:
            timeout (float): Wait this long (in seconds) before giving up on waiting.
            grace_period (float): When any processes fail, wait this long (in seconds)
                for others to shutdown gracefully before terminating them. If they
                still don't exit, wait another grace period before killing them.
        r   T)rO   Nz)Terminating process %s via signal SIGTERMé   zJUnable to shutdown process %s via SIGTERM , forcefully exiting via SIGKILLz<Unknown signal ú>zprocess Údz terminated with signal )r   r   r-   r.   z terminated with exit code )r   r   r-   Úrbz

-- Process z& terminated with the following error:
)ÚlenrJ   ÚmultiprocessingÚ
connectionÚwaitÚkeysÚpoprG   rT   ÚexitcoderW   Úis_aliveÚlogÚwarningr   Ú	terminateÚkillÚosÚaccessrF   ÚR_OKr3   ÚSignalsÚnameÚ
ValueErrorr   r8   r9   Úloadr   )r   rO   rX   Úreadyr   rI   rK   rL   Úfailed_processrd   rn   rB   Úoriginal_tracer   s                 r   rT   zProcessContext.joinx   sÆ  € ô( ˆt�~‰~Ó !Ò#Øô  ×*Ñ*×/Ñ/Ø�N‰N×ÑÓ!Øð 0ó 
ˆð
 ˆØò 	ˆHØ—N‘N×&Ñ& xÓ0ˆEØ—n‘n UÑ+ˆGØ�L‰LŒNØ×Ñ 1Ó$Ø#�Ùð	ð Ðä�t—~‘~Ó&¨!Ñ+Ð+ð Ð#Ø×)Ñ)¨,Ô7à—~‘~ò 	$ˆGØ×ÑÕ!Ü—‘ÐGÈÏÉÔUØ×!Ñ!Õ#ð	$ð 	×%Ñ%¨LÐ,@¡bÀlÔSØ—~‘~ò 	ˆGØ×ÑÔ!Ü—‘Ø`Ø—K‘Kôð —‘”Ø�L‰L�Nð	ð Ÿ™¨Ñ4ˆÜ�y‰y˜×)Ñ)¨+Ñ6¼¿¹Ô@Ø—~‘~ kÑ2×;Ñ;ˆHØ˜!Š|ð;Ü!Ÿ>™>¨8¨)Ó4×9Ñ9�Dô -Ø˜{¨1˜oÐ-EÀdÀVÐLØ +Ø,×0Ñ0Ø&Ø $ôð ô -Ø˜{¨1˜oÐ-HÈÐRSÈÐUØ +Ø,×0Ñ0Ø&ô	ð ô �$×"Ñ" ;Ñ/°Ó6ð 	-¸"Ü#Ÿ[™[¨›_ˆN÷	-à ¨A˜Ð.UÐVˆØˆ~ÑˆÜ$ S¨+°~×7IÑ7IÓJÐJøô+ "ò ;Ø-¨x¨i¨[¸Ð:’Dð;ú÷"	-ð 	-ús   Ç= J9 É8KÊ9KËKËK)NN)	r!   r"   r#   r   rN   ÚfloatrW   r   rT   © r   r   r	   r	   f   sC   „ ò
ò@ð'°ó 'ð PTñ_KØ ‘ð_KØ=EÀe¹_ô_Kr   r	   c                   ó   ‡ — e Zd Zˆ fd„Zˆ xZS )r   c                 óP   •— t        j                  d«       t        ‰| �  ||«       y )Nz<SpawnContext is renamed to ProcessContext since 1.4 release.)ÚwarningsÚwarnr   r   )r   rG   rF   r   s      €r   r   zSpawnContext.__init__Û   s   ø€ Ü�‰ÐTÔUÜ‰Ñ˜ KÕ0r   )r!   r"   r#   r   r'   r(   s   @r   r   r   Ú   s   ø„ ÷1ð 1r   r   c                 óœ  ‡ ‡‡‡— |dk(  r?t         j                  j                  t        d«      dk(  rt        j                  d«       d}nd}t        j                  |«      Šd g|z  }d g|z  }ˆˆˆ ˆfd„}	|s't        |«      D ]  }
 |	|
«      \  }}}|||<   |||<   Œ nlt        |¬«      5 }t        |«      D �
cg c]  }
|j                  |	|
«      ‘Œ }}
t        |«      D ]   }|j                  «       \  }}}|||<   |||<   Œ" 	 d d d «       t        ||«      }|s|S |j                  «       s	 |j                  «       sŒy y c c}
w # 1 sw Y   ŒBxY w)	NÚ
forkserverÚ0Ú1zStarting processes in parallel.TFc                 ó  •— t        j                  ddd¬«      }|j                  «        t        j                  |j
                  «       ‰j                  t        ‰| ‰|j
                  f‰¬«      }|j                  «        | ||j
                  fS )Nzpytorch-errorfile-z.pickleF)ÚprefixÚsuffixÚdelete)Útargetr@   Údaemon)	ÚtempfileÚNamedTemporaryFileÚcloserj   Úunlinkrn   ÚProcessrC   Ústart)r?   ÚtfrL   r@   rƒ   r>   Úmps      €€€€r   Ústart_processz&start_processes.<locals>.start_process  s|   ø€ ô ×(Ñ(Ø'°	À%ô
ˆð 	�‰Œ
Ü
�	‰	�"—'‘'ÔØ—*‘*ÜØ�a˜˜rŸw™wÐ'Øð ó 
ˆð
 	�‰ŒØ�'˜2Ÿ7™7Ð"Ð"r   )Úmax_workers)rj   ÚenvironÚgetÚENV_VAR_PARALLEL_STARTrf   Úinfor_   Úget_contextÚranger   Úsubmitr   Úresultr	   rT   )r>   r@   ÚnprocsrT   rƒ   Ústart_methodÚstart_parallelrF   rG   rŒ   r?   ÚidxrL   Útf_nameÚexecutorÚfuturesÚfutÚcontextr‹   s   ``  `             @r   r   r   è   sV  û€ ð 	˜Ò$Ü�J‰J�N‰NÔ1°3Ó7¸3Ò>ä�‰Ð2Ô3Ø‰ð ˆä	×	$Ñ	$ \Ó	2€BØ�&˜6‘/€KØ�˜‘€I÷#ñ( Ü�v“ò 	%ˆAÙ$1°!Ó$4Ñ!ˆC�˜'Ø&ˆK˜ÑØ$ˆI�cŠNñ	%ô
  ¨FÔ3ð 	)°xÜBGÈÃ-ÖP¸Q�x—‘ }°aÕ8ÐPˆGÐPÜ# GÓ,ò )�Ø(+¯
©
«Ñ%��W˜gà#*�˜CÑ Ø!(�	˜#’ñ	)÷	)ô ˜Y¨Ó4€GÙØˆð �l‰lŒnØð �l‰l�nùò Q÷	)ð 	)ús   Â)EÂ7D=Ã0EÄ=EÅEc                 ór   — |dk7  r"d|› d�}t        j                  |t        d¬«       t        | ||||d¬«      S )a¶  Spawns ``nprocs`` processes that run ``fn`` with ``args``.

    If one of the processes exits with a non-zero exit status, the
    remaining processes are killed and an exception is raised with the
    cause of termination. In the case an exception was caught in the
    child process, it is forwarded and its traceback is included in
    the exception raised in the parent process.

    Args:
        fn (function): Function is called as the entrypoint of the
            spawned process. This function must be defined at the top
            level of a module so it can be pickled and spawned. This
            is a requirement imposed by multiprocessing.

            The function is called as ``fn(i, *args)``, where ``i`` is
            the process index and ``args`` is the passed through tuple
            of arguments.

        args (tuple): Arguments passed to ``fn``.
        nprocs (int): Number of processes to spawn.
        join (bool): Perform a blocking join on all processes.
        daemon (bool): The spawned processes' daemon flag. If set to True,
                       daemonic processes will be created.
        start_method (str): (deprecated) this method will always use ``spawn``
                               as the start method. To use a different start method
                               use ``start_processes()``.

    Returns:
        None if ``join`` is ``True``,
        :class:`~ProcessContext` if ``join`` is ``False``

    r   z3This method only supports start_method=spawn (got: zU).
To use a different start_method use:
		 torch.multiprocessing.start_processes(...)é   )Ú
stacklevel)r—   )rx   ry   ÚFutureWarningr   )r>   r@   r–   rT   rƒ   r—   r   s          r   r   r   ,  sK   € ðB �wÒàAÀ,Àð P:ð :ð 	ô
 	�‰�cœ=°QÕ7Ü˜2˜t V¨T°6ÈÔPÐPr   )ru   r   TFr   )Úloggingr_   Úmultiprocessing.connectionrj   r9   r3   r<   r„   rQ   rx   Úconcurrent.futuresr   r   Útypingr   Ú r   r�   Ú	getLoggerr!   rf   Ú__all__r6   r
   r   r   rC   r	   r   r   r   ru   r   r   ú<module>rª      s³   ðã Û Û !Û 	Û Û Û 
Û Û Û ß ?Ý å %ð 3Ð à€g×Ñ˜Ó!€ò€ô
B�yô 
Bô	6Ð-ô 	6ô
Ð-ô 
ò0÷(qKñ qKôh1�>ô 1ð  
ØØ	ØØóAôH(Qr   