
    )`iY              
           d Z ddlmZmZmZ ddlZddlmZ ddlm	Z	 	 ddee
gee	         f         de
d	ed
ee	         fdZdS )u   
Shared polling utilities for task operations.

This module provides generic polling logic that works for both client→server
and server→client task polling.

WARNING: These APIs are experimental and may change without notice.
    )AsyncIterator	AwaitableCallableN)is_terminal)GetTaskResult  get_tasktask_iddefault_interval_msreturnc                   K   	  | |           d{V }|W V  t          |j                  rdS |j        |j        n|}t          j        |dz             d{V  Z)u  
    Poll a task until it reaches terminal status.

    This is a generic utility that works for both client→server and server→client
    polling. The caller provides the get_task function appropriate for their direction.

    Args:
        get_task: Async function that takes task_id and returns GetTaskResult
        task_id: The task to poll
        default_interval_ms: Fallback poll interval if server doesn't specify

    Yields:
        GetTaskResult for each poll
    TNi  )r   statuspollIntervalanyiosleep)r	   r
   r   r   interval_mss        y/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/mcp/shared/experimental/tasks/polling.pypoll_until_terminalr      s      &.x((((((((v}%% 	E-3-@-Lf))Rek+,---------.    )r   )__doc__collections.abcr   r   r   r   %mcp.shared.experimental.tasks.helpersr   	mcp.typesr   strintr    r   r   <module>r      s     ? > > > > > > > > >  = = = = = = # # # # # #  #. .ui667.. . =!	. . . . . .r   