Ë
    ÄÓ^j  ã                   ó6   — d Z ddlmZ ddlmZ deded   fd„Zy)z§
Utility functions for the experimental checkpoint module.

This module contains helper functions and utilities used across the experimental
checkpoint functionality.
é    )ÚFuture)ÚAnyÚoriginal_resultÚreturnNc                 ó²   ‡ ‡— t        «       Št        ‰ t         «      r)dt         t           ddfˆˆ fd„}‰ j                  |«       ‰S ‰j	                  d«       ‰S )aì  
    Wraps a result (Future or not) to return a Future with None result.

    If the input is a Future, returns a new Future that completes with None when
    the original Future completes successfully, or propagates any exception.
    If the input is not a Future, returns a completed Future with None result.

    Args:
        original_result: The result to wrap (Future or any other value).

    Returns:
        A Future that completes with None on success or propagates exceptions.
    Ú_r   Nc                 ó˜   •— 	 ‰j                  «        ‰j                  d «       y # t        $ r}‰j                  |«       Y d }~y d }~ww xY w)N)ÚresultÚ
set_resultÚ	ExceptionÚset_exception)r   ÚeÚmasked_futurer   s     €€ú{/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/torch/distributed/checkpoint/_experimental/utils.pyÚon_completez wrap_future.<locals>.on_complete   sC   ø€ ð/Ø×&Ñ&Ô(Ø×(Ñ(¨Õ.øÜò /Ø×+Ñ+¨A×.Ñ.ûð/ús   ƒ!% ¥	A	®AÁA	)r   Ú
isinstancer   Úadd_done_callbackr   )r   r   r   s   ` @r   Úwrap_futurer      s[   ù€ ô #)£(€Mä�/¤6Ô*ð	/œ6¤#™;ð 	/¨4ö 	/ð 	×)Ñ)¨+Ô6ð
 Ðð 	× Ñ  Ô&àÐó    )Ú__doc__Úconcurrent.futuresr   Útypingr   r   © r   r   ú<module>r      s)   ðñõ &Ý ð ð ¨°©ô r   