o
    i	                     @  s|   d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZmZmZmZmZ ddlmZ G dd	 d	eeef Zd
S )    )annotations)Callable)InputTOperationInfoOutputT)is_async_callable)CancelOperationContextFetchOperationInfoContextFetchOperationResultContextStartOperationContextStartOperationResultSync   )OperationHandlerc                   @  sB   e Zd ZdZdddZdddZdddZd ddZd!ddZdS )"SyncOperationHandlera  
    An :py:class:`nexusrpc.handler.OperationHandler` that is limited to responding synchronously.

    The name 'SyncOperationHandler' means that it responds synchronously, in the
    sense that the start method delivers the final operation result as its return
    value, rather than returning an operation token representing an in-progress
    operation.

    This version of the class uses `def` methods. For the async version, see
    :py:class:`nexusrpc.handler.SyncOperationHandler`.
    start2Callable[[StartOperationContext, InputT], OutputT]c                 C  sH   t |rt| d|| _|jr t| jdd  }r"|j|_d S d S d S )Nz is an `async def` method. SyncOperationHandler must be initialized with a `def` method. To use `async def` methods, use nexusrpc.handler.SyncOperationHandler.__func__)r   RuntimeError_start__doc__getattrr   )selfr   
start_func r   ^/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/nexusrpc/handler/_syncio.py__init__#   s   zSyncOperationHandler.__init__ctxr   inputr   return!StartOperationResultSync[OutputT]c                 C  s   t | ||S )zP
        Start the operation and return its final result synchronously.
        )r   r   )r   r   r   r   r   r   r   /   s   zSyncOperationHandler.startr	   tokenstrr   c                 C     t d)NzJCannot fetch operation info for an operation that responded synchronously.NotImplementedErrorr   r   r    r   r   r   
fetch_info7      zSyncOperationHandler.fetch_infor
   r   c                 C  r"   )NzECannot fetch the result of an operation that responded synchronously.r#   r%   r   r   r   fetch_result<   r'   z!SyncOperationHandler.fetch_resultr   Nonec                 C  r"   )Nz>An operation that responded synchronously cannot be cancelled.r#   r%   r   r   r   cancelA   r'   zSyncOperationHandler.cancelN)r   r   )r   r   r   r   r   r   )r   r	   r    r!   r   r   )r   r
   r    r!   r   r   )r   r   r    r!   r   r)   )	__name__
__module____qualname__r   r   r   r&   r(   r*   r   r   r   r   r      s    



r   N)
__future__r   typingr   nexusrpc._commonr   r   r   nexusrpc._utilr   nexusrpc.handler._commonr   r	   r
   r   r   _operation_handlerr   r   r   r   r   r   <module>   s    