o
    Zhq
                     @   sl   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d Z
ejd	d
 Zdd ZG dd dZdS )    )partialN)Future   )	functions	rpc_async)UNSET_RPC_TIMEOUTc                 C      t |  ||i |S NgetattrZlocal_valuerref	func_nameargskwargs r   O/var/www/auris/lib/python3.10/site-packages/torch/distributed/rpc/rref_proxy.py_local_invoke   s   r   c                 C   r   r	   r
   r   r   r   r   _local_invoke_async_execution   s   r   c                    sl   fddj dd}tkr|  |S t  fdd}fdd || S )	Nc                    s`   |   }t}t|tjjpt|tjj}|s"t|}t|dr"t	}
 | fdS )NZ_wrapped_async_rpc_function)r   timeout)valuer   
issubclasstorchZjitZScriptModuleZ_Cr   hasattrr   owner)rref_futZ	rref_typeZ_invoke_funcZbypass_typefunc)r   r   r   rpc_apir   r   r   r   _rref_type_cont   s   


z$_invoke_rpc.<locals>._rref_type_contF)r   blockingc              
      sF   z
|    W d S  ty" } z| W Y d }~d S d }~ww r	   )thenBaseExceptionset_exceptionfutex)_complete_opr   resultr   r   _wrap_rref_type_cont5      z)_invoke_rpc.<locals>._wrap_rref_type_contc              
      sF   z
  |   W d S  ty" } z | W Y d }~d S d }~ww r	   )
set_resultr   r!   r"   r#   )r'   r   r   r&   ;   r)   z!_invoke_rpc.<locals>._complete_op)Z	_get_typer   waitr   r    )r   r   r   r   r   r   r   r(   r   )	r&   r   r   r   r   r'   r   r   r   r   _invoke_rpc   s   
r,   c                   @   s    e Zd ZefddZdd ZdS )	RRefProxyc                 C   s   || _ || _|| _d S r	   )r   r   rpc_timeout)selfr   r   r   r   r   r   __init__H   s   
zRRefProxy.__init__c                 C   s   t t| j| j|| jS r	   )r   r,   r   r   r.   )r/   r   r   r   r   __getattr__M   s   zRRefProxy.__getattr__N)__name__
__module____qualname__r   r0   r1   r   r   r   r   r-   G   s    r-   )	functoolsr   r   Ztorch.futuresr    r   r   	constantsr   r   Zasync_executionr   r,   r-   r   r   r   r   <module>   s   
3