
    sg                         d dl Z d dlmZmZ d dlmZ d dlmZ dgZdZ	ede
ded	   fd
       Zeeded	   fd              Zy)    N)contextmanager	ExitStack)	Generator)recordworker_mainTORCH_WORKER_SERVER_SOCKETsocket_pathreturn)NNNc              #   |   K   ddl m}  ||       }	 d  |j                          y # |j                          w xY ww)Nr   )_WorkerServer)torch._C._distributed_c10dr   shutdown)r	   r   servers      Z/var/www/html/venv/lib/python3.12/site-packages/torch/distributed/elastic/control_plane.py_worker_serverr      s/     8;'Fs   <' <9<c               #      K   t               5 } t        j                  j                  t              }|| j                  t        |             d ddd       y# 1 sw Y   yxY ww)aw  
    This is a context manager that wraps your main entry function. This combines
    the existing ``errors.record`` logic as well as a new ``_WorkerServer`` that
    exposes handlers via a unix socket specified by
    ``Torch_WORKER_SERVER_SOCKET``.

    Example

    ::

     @worker_main()
     def main():
         pass

     if __name__=="__main__":
        main()

    N)r   osenvirongetr   enter_contextr   )stackr	   s     r   r   r      sR     * 
 jjnn%?@"{ ;<  s   A&AA	A&A#A&)r   
contextlibr   r   typingr   0torch.distributed.elastic.multiprocessing.errorsr   __all__r   strr   r        r   <module>r      sv    	 0  C  :   	2B(C   Y/0   r   