
    sgq
                         d dl mZ d dlZd dlmZ ddlmZmZ ddlm	Z	 d Z
ej                  d        Zd	 Z G d
 d      Zy)    )partialN)Future   )	functions	rpc_async)UNSET_RPC_TIMEOUTc                 B     t        | j                         |      |i |S Ngetattrlocal_valuerref	func_nameargskwargss       S/var/www/html/venv/lib/python3.12/site-packages/torch/distributed/rpc/rref_proxy.py_local_invoker      s$    174##%y14B6BB    c                 B     t        | j                         |      |i |S r
   r   r   s       r   _local_invoke_async_executionr      s$    174##%y14B6BBr   c                     	
  fd	 j                  d      }t        k7  r|j                           	|      S t               
	
fd}
fd|j	                  |       
S )Nc                 @   | j                         }t        }t        |t        j                  j
                        xs$ t        |t        j                  j
                        }|st        |      }t        |d      rt        } 	j                         |	f
      S )N_wrapped_async_rpc_function)r   timeout)valuer   
issubclasstorchjitScriptModule_Cr   hasattrr   owner)rref_fut	rref_type_invoke_funcbypass_typefuncr   r   r   rpc_apir   r   s        r   _rref_type_contz$_invoke_rpc.<locals>._rref_type_cont   s    NN$	$ EII,B,BC 
zuxx,,H
 9i0Dt:;<JJL	40	
 	
r   F)r   blockingc                     	  |       j                         y # t        $ r}j                  |       Y d }~y d }~ww xY wr
   )thenBaseExceptionset_exception)futex_complete_opr*   results     r   _wrap_rref_type_contz)_invoke_rpc.<locals>._wrap_rref_type_cont5   s<    )$)),7  )$$R(()s    	?:?c                     	 j                  | j                                y # t        $ r}j                  |       Y d }~y d }~ww xY wr
   )
set_resultr   r.   r/   )r0   r1   r3   s     r   r2   z!_invoke_rpc.<locals>._complete_op;   s=    )!!#))+.  )$$R(()s   # 	AAA)	_get_typer   waitr   r-   )r   r)   r   r   r   r   r$   r4   r2   r*   r3   s   ``````  @@@r   _invoke_rpcr9      se    
 
( ~~g~>H)x((  	)	) 	*+r   c                       e Zd ZefdZd Zy)	RRefProxyc                 .    || _         || _        || _        y r
   )r   r)   rpc_timeout)selfr   r)   r   s       r   __init__zRRefProxy.__init__H   s    	"r   c                 d    t        t        | j                  | j                  || j                        S r
   )r   r9   r   r)   r=   )r>   r   s     r   __getattr__zRRefProxy.__getattr__M   s(    DLL)T=M=M
 	
r   N)__name__
__module____qualname__r   r?   rA    r   r   r;   r;   G   s    .? #

r   r;   )	functoolsr   r   torch.futuresr    r   r   	constantsr   r   async_executionr   r9   r;   rE   r   r   <module>rK      sF        " (C C C.f	
 	
r   