o
    *iY                  
   @   sl   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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                 C  sP   	 | |I dH }|V  t |jrdS |jdur|jn|}t|d I dH  q)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_ms r   b/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/mcp/shared/experimental/tasks/polling.pypoll_until_terminal   s   
r   )r   )__doc__collections.abcr   r   r   r   %mcp.shared.experimental.tasks.helpersr   	mcp.typesr   strintr   r   r   r   r   <module>   s    	