
    )`i	                     d    d Z ddlmZmZmZ ddlZ ed          Z G d dee                   ZdS )z
Resolver - An anyio-compatible future-like object for async result passing.

This provides a simple way to pass a result (or exception) from one coroutine
to another without depending on asyncio.Future.
    )GenericTypeVarcastNTc                   R    e Zd ZdZddZdeddfdZdeddfdZdefd	Z	de
fd
ZdS )Resolverai  
    A simple resolver for passing results between coroutines.

    Unlike asyncio.Future, this works with any anyio-compatible async backend.

    Usage:
        resolver: Resolver[str] = Resolver()

        # In one coroutine:
        resolver.set_result("hello")

        # In another coroutine:
        result = await resolver.wait()  # returns "hello"
    returnNc                 R    t          j                    | _        d | _        d | _        d S )N)anyioEvent_event_value
_exceptionselfs    z/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/mcp/shared/experimental/tasks/resolver.py__init__zResolver.__init__   s!    kmm $04    valuec                     | j                                         rt          d          || _        | j                                          dS )z)Set the result value and wake up waiters.Resolver already completedN)r   is_setRuntimeErrorr   set)r   r   s     r   
set_resultzResolver.set_result$   sF    ; 	=;<<<r   excc                     | j                                         rt          d          || _        | j                                          dS )z%Set an exception and wake up waiters.r   N)r   r   r   r   r   )r   r   s     r   set_exceptionzResolver.set_exception+   sF    ; 	=;<<<r   c                    K   | j                                          d{V  | j        | j        t          t          | j                  S )z:Wait for the result and return it, or raise the exception.N)r   waitr   r   r   r   r   s    r   r    zResolver.wait2   sN      k         ?&/!At{###r   c                 4    | j                                         S )z/Return True if the resolver has been completed.)r   r   r   s    r   donezResolver.done:   s    {!!###r   )r	   N)__name__
__module____qualname____doc__r   r   r   BaseExceptionr   r    boolr"    r   r   r   r      s         5 5 5 5
 d     4    $A $ $ $ $$d $ $ $ $ $ $r   r   )r&   typingr   r   r   r   r   r   r)   r   r   <module>r+      s}     * ) ) ) ) ) ) ) ) ) GCLL-$ -$ -$ -$ -$wqz -$ -$ -$ -$ -$r   