
    ȅi                     8    S r SSKJr  SSKJr  S\S\S   4S jrg)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                    ^ ^ [        5       m[        T [         5      (       a+  S[         [           SS4UU 4S jjnT R                  U5        T$ TR	                  S5        T$ )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                    >  TR                  5         TR                  S 5        g ! [         a  nTR                  U5         S nAg S nAff = f)N)result
set_result	Exceptionset_exception)r   emasked_futurer   s     j/home/james-whalen/.local/lib/python3.13/site-packages/torch/distributed/checkpoint/_experimental/utils.pyon_complete wrap_future.<locals>.on_complete   sC    /&&(((. /++A../s   !% 
A
AA
)r   
isinstancer   add_done_callbackr   )r   r   r   s   ` @r   wrap_futurer      sc     #)(M/6**	/6#; 	/4 	/ 	/ 	))+6
  	  &    )__doc__concurrent.futuresr   typingr   r    r   r   <module>r      s)    &   r   