o
    Zh                     @   sr   d dl Z d dlmZ d dlmZmZ d dlmZ dgZdZ	ede
ded	 fd
dZeeded	 fddZdS )    N)	Generator)contextmanager	ExitStack)recordworker_mainTORCH_WORKER_SERVER_SOCKETsocket_pathreturn)NNNc                 c   s6    ddl m} || }z
d V  W |  d S |  w )Nr   )_WorkerServer)Ztorch._C._distributed_c10dr
   shutdown)r   r
   server r   V/var/www/auris/lib/python3.10/site-packages/torch/distributed/elastic/control_plane.py_worker_server   s   r   c                  c   sV    t  } tjt}|dur| t| dV  W d   dS 1 s$w   Y  dS )a{  
    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   r   r   r   r      s   ")r   collections.abcr   
contextlibr   r   Z0torch.distributed.elastic.multiprocessing.errorsr   __all__r   strr   r   r   r   r   r   <module>   s    
