
    KiY              
       p    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y)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{   }| t        |j                        ry|j                  |j                  n|}t        j                  |dz         d{    f7 Z7 w)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
    Ni  )r   statuspollIntervalanyiosleep)r   r	   r
   r   interval_mss        q/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/mcp/shared/experimental/tasks/polling.pypoll_until_terminalr      sj     & ((v}}%-3-@-@-Lf))Rekk+,--- ( 	.s"   A.A*AA.$A,%A.,A.)i  )__doc__collections.abcr   r   r   r   %mcp.shared.experimental.tasks.helpersr   	mcp.typesr   strintr        r   <module>r      s_    ? >  = #  #.ui667.. . =!	.r   