
    !<ied              
          U d dl Z d dlZd dlZd dlZd dlmZ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mZmZmZmZmZmZmZ ddlmZ dd	lmZmZm Z m!Z! dd
l"m#Z# erddl$m%Z%  G d de j&                  Z' G d de'          Z(dIdZ) G d de'          Z*defdZ+ G d de'          Z,defdZ- G d de'          Z.de/fdZ0 G d de'          Z1dJde/dz  d e2defd!Z3 G d" d#e'          Z4dKd%Z5 G d& d'e'          Z6 G d( d)e7          Z8 G d* d+e'          Z9 G d, d-e9          Z: G d. d/e'          Z; G d0 d1e'          Z< ed2          Z=ed3e=ee=         z  ee=         z  ee=         z  f         Z>i Z?e@e e>e         z  e@e/e'f         f         eAd4<   d5e e>e         z  de@e/e'f         fd6ZB G d7 d8e'ee=                   ZCd9e>e=         de=fd:ZD G d; d<e'          ZE ed=e'>          ZFd5e d?eGeF         deFdz  fd@ZHdAe@e/e'f         d?eGeF         deFdz  fdBZId5e ddfdCZJ G dD dE          ZKedFddGedee@e/ef         df         fdH            ZLdS )L    N)AsyncExitStackasynccontextmanager)
ContextVar)datetime	timedeltatimezone)TracebackType)TYPE_CHECKINGAnyAsyncContextManagerAsyncGenerator	AwaitableCallableContextManagerCounterGenericNoReturnTypeVarcast   )Docket)	ExecutionExecutionProgressTaskFunctionget_signature)
CACHE_SIZE)Workerc                       e Zd ZU dZeed<    ed          Zee         ed<    ed          Z	ed         ed<    ed          Z
ee         ed<   ej        defd            Zd	ee         d
z  ded
z  ded
z  defdZd
S )
DependencyFsingledocketworkerr   	executionreturnc                 
   K   d S N selfs    /Users/kimhansen/Desktop/03 Workspace/ceo-agents/chl-effectiveness/mcp-servers/whoop/.venv/lib/python3.11/site-packages/docket/dependencies.py
__aenter__zDependency.__aenter__(   s      '*s    	_exc_typeN
_exc_value
_tracebackc                 
   K   d S r&   r'   )r)   r-   r.   r/   s       r*   	__aexit__zDependency.__aexit__+   s      
 sr,   )__name__
__module____qualname__r    bool__annotations__r   r!   r   r"   r#   r   abcabstractmethodr   r+   typeBaseExceptionr	   r1   r'   r,   r*   r   r   !   s         FD!+H!5!5FJv555#-:h#7#7FJx 777'1z+'>'>Iz)$>>>*#*** *&- "D( "D(	
 
     r,   r   c                       e Zd ZddZdS )_CurrentWorkerr$   r   c                 8   K   | j                                         S r&   )r"   getr(   s    r*   r+   z_CurrentWorker.__aenter__4         {   r,   Nr$   r   r2   r3   r4   r+   r'   r,   r*   r<   r<   3   s(        ! ! ! ! ! !r,   r<   r$   r   c                  :    t          dt                                S )zA dependency to access the current Worker.

    Example:

    ```python
    @task
    async def my_task(worker: Worker = CurrentWorker()) -> None:
        assert isinstance(worker, Worker)
    ```
    r   )r   r<   r'   r,   r*   CurrentWorkerrC   8   s     .**+++r,   c                       e Zd ZdefdZdS )_CurrentDocketr$   c                 8   K   | j                                         S r&   )r!   r>   r(   s    r*   r+   z_CurrentDocket.__aenter__G   r?   r,   N)r2   r3   r4   r   r+   r'   r,   r*   rE   rE   F   s/        !& ! ! ! ! ! !r,   rE   c                  D    t          t          t                                S )zA dependency to access the current Docket.

    Example:

    ```python
    @task
    async def my_task(docket: Docket = CurrentDocket()) -> None:
        assert isinstance(docket, Docket)
    ```
    )r   r   rE   r'   r,   r*   CurrentDocketrH   K   s     (()))r,   c                       e Zd ZdefdZdS )_CurrentExecutionr$   c                 8   K   | j                                         S r&   )r#   r>   r(   s    r*   r+   z_CurrentExecution.__aenter__Z   s      ~!!###r,   N)r2   r3   r4   r   r+   r'   r,   r*   rJ   rJ   Y   s/        $) $ $ $ $ $ $r,   rJ   c                  D    t          t          t                                S )zA dependency to access the current Execution.

    Example:

    ```python
    @task
    async def my_task(execution: Execution = CurrentExecution()) -> None:
        assert isinstance(execution, Execution)
    ```
    )r   r   rJ   r'   r,   r*   CurrentExecutionrM   ^   s     	,..///r,   c                       e Zd ZdefdZdS )_TaskKeyr$   c                 B   K   | j                                         j        S r&   )r#   r>   keyr(   s    r*   r+   z_TaskKey.__aenter__m   s      ~!!##''r,   N)r2   r3   r4   strr+   r'   r,   r*   rO   rO   l   s/        (# ( ( ( ( ( (r,   rO   c                  D    t          t          t                                S )zA dependency to access the key of the currently executing task.

    Example:

    ```python
    @task
    async def my_task(key: str = TaskKey()) -> None:
        assert isinstance(key, str)
    ```
    )r   rR   rO   r'   r,   r*   TaskKeyrT   q   s     XZZ   r,   c                   R    e Zd ZU edz  ed<   eed<   ddedz  deddfdZdefdZdS )	_TaskArgumentN	parameteroptionalFr$   c                 "    || _         || _        d S r&   rW   rX   )r)   rW   rX   s      r*   __init__z_TaskArgument.__init__   s    " r,   c                    K   | j         J | j                                        }	 |                    | j                   S # t          $ r | j        rY d S  w xY wr&   )rW   r#   r>   get_argumentKeyErrorrX   r)   r#   s     r*   r+   z_TaskArgument.__aenter__   sq      ~)))N&&((		))$.999 	 	 	} tt	s   A   AANF)	r2   r3   r4   rR   r6   r5   r[   r   r+   r'   r,   r*   rV   rV      s}         TzNNN! !#* !t !PT ! ! ! !#      r,   rV   FrW   rX   c                 H    t          t          t          | |                    S )a   A dependency to access a argument of the currently executing task.  This is
    often useful in dependency functions so they can access the arguments of the
    task they are injected into.

    Example:

    ```python
    async def customer_name(customer_id: int = TaskArgument()) -> str:
        ...look up the customer's name by ID...
        return "John Doe"

    @task
    async def greet_customer(customer_id: int, name: str = Depends(customer_name)) -> None:
        print(f"Hello, {name}!")
    ```
    )r   r   rV   rZ   s     r*   TaskArgumentrb      s    " ]9h77888r,   c                       e Zd ZddZdS )_TaskLoggerr$   %logging.LoggerAdapter[logging.Logger]c                 x  K   | j                                         }t          j        d|j        j                   }t          j        |i | j                                                                        | j	                                                                        |
                                          S )Nzdocket.task.)r#   r>   logging	getLoggerfunctionr2   LoggerAdapterr!   labelsr"   specific_labels)r)   r#   loggers      r*   r+   z_TaskLogger.__aenter__   s      N&&((	"#O)2D2M#O#OPP$+//##**,,+//##**,, ++--
 
 	
r,   Nr$   re   rA   r'   r,   r*   rd   rd      s(        

 

 

 

 

 

r,   rd   re   c                  :    t          dt                                S )a  A dependency to access a logger for the currently executing task.  The logger
    will automatically inject contextual information such as the worker and docket
    name, the task key, and the current execution attempt number.

    Example:

    ```python
    @task
    async def my_task(logger: "LoggerAdapter[Logger]" = TaskLogger()) -> None:
        logger.info("Hello, world!")
    ```
    re   )r   rd   r'   r,   r*   
TaskLoggerrp      s     7GGGr,   c                       e Zd ZdZddZddZededz  fd            Zedefd            Z	ede
dz  fd            Zd	eddfd
ZddeddfdZde
dz  ddfdZdS )Progressa9  A dependency to report progress updates for the currently executing task.

    Tasks can use this to report their current progress (current/total values) and
    status messages to external observers.

    Example:

    ```python
    @task
    async def process_records(records: list, progress: Progress = Progress()) -> None:
        await progress.set_total(len(records))
        for i, record in enumerate(records):
            await process(record)
            await progress.increment()
            await progress.set_message(f"Processed {record.id}")
    ```
    r$   Nc                     d | _         d S r&   )	_progressr(   s    r*   r[   zProgress.__init__   s    37r,   c                 T   K   | j                                         }|j        | _        | S r&   )r#   r>   progressrt   r_   s     r*   r+   zProgress.__aenter__   s(      N&&((	"+r,   c                 <    | j         
J d            | j         j        S )zCurrent progress value.N%Progress must be used as a dependency)rt   currentr(   s    r*   ry   zProgress.current   &     ~))+R)))~%%r,   c                 <    | j         
J d            | j         j        S )z)Total/target value for progress tracking.Nrx   )rt   totalr(   s    r*   r|   zProgress.total   s&     ~))+R)))~##r,   c                 <    | j         
J d            | j         j        S )zUser-provided status message.Nrx   )rt   messager(   s    r*   r~   zProgress.message   rz   r,   r|   c                 l   K   | j         
J d            | j                             |           d{V  dS )z1Set the total/target value for progress tracking.Nrx   )rt   	set_total)r)   r|   s     r*   r   zProgress.set_total   sK      ~))+R)))n&&u-----------r,   r   amountc                 l   K   | j         
J d            | j                             |           d{V  dS )z0Atomically increment the current progress value.Nrx   )rt   	increment)r)   r   s     r*   r   zProgress.increment   sK      ~))+R)))n&&v...........r,   r~   c                 l   K   | j         
J d            | j                             |           d{V  dS )z#Update the progress status message.Nrx   )rt   set_message)r)   r~   s     r*   r   zProgress.set_message   sK      ~))+R)))n((11111111111r,   r$   N)r$   rr   )r   )r2   r3   r4   __doc__r[   r+   propertyintry   r|   rR   r~   r   r   r   r'   r,   r*   rr   rr      s2        $8 8 8 8   
 &t & & & X&
 $s $ $ $ X$
 &t & & & X&
.S .T . . . .
/ /c /$ / / / /
2t 2 2 2 2 2 2 2r,   rr   c                       e Zd ZdZdS )ForcedRetryz5Raised when a task requests a retry via `in_` or `at`N)r2   r3   r4   r   r'   r,   r*   r   r     s        ????r,   r   c                   |    e Zd ZU dZdZeed<   d ed          fdedz  ded	dfd
Z	ddZ
ded	efdZded	efdZdS )Retrya  Configures linear retries for a task.  You can specify the total number of
    attempts (or `None` to retry indefinitely), and the delay between attempts.

    Example:

    ```python
    @task
    async def my_task(retry: Retry = Retry(attempts=3)) -> None:
        ...
    ```
    Tr    r   r   attemptsNdelayr$   c                 0    || _         || _        d| _        dS )z
        Args:
            attempts: The total number of attempts to make.  If `None`, the task will
                be retried indefinitely.
            delay: The delay between attempts.
        r   N)r   r   attempt)r)   r   r   s      r*   r[   zRetry.__init__  s     !
r,   c                    K   | j                                         }t          | j        | j                  }|j        |_        |S )Nr   r   )r#   r>   r   r   r   r   )r)   r#   retrys      r*   r+   zRetry.__aenter__!  s>      N&&((	t}DJ???!)r,   whenc                     t          j        t          j                  }||z
  }|                                dk    r|nt          d          }|                     |           d S )Nr   )r   nowr   utctotal_secondsr   in_)r)   r   r   diffs       r*   atzRetry.at'  sT    l8<((cz))++q00ttillr,   c                 ,    || _         t                      r&   )r   r   )r)   r   s     r*   r   z	Retry.in_.  s     $
mmr,   )r$   r   )r2   r3   r4   r   r    r5   r6   r   r   r[   r+   r   r   r   r   r'   r,   r*   r   r     s         
 
 FD &'99Q<< d
/8	      x H    	 h      r,   r   c            	       r     e Zd ZdZd ed           ed          fdedz  deded	df fd
ZddZ xZS )ExponentialRetryaO  Configures exponential retries for a task.  You can specify the total number
    of attempts (or `None` to retry indefinitely), and the minimum and maximum delays
    between attempts.

    Example:

    ```python
    @task
    async def my_task(retry: ExponentialRetry = ExponentialRetry(attempts=3)) -> None:
        ...
    ```
    r   seconds@   r   Nminimum_delaymaximum_delayr$   c                 \    t                                          ||           || _        dS )a  
        Args:
            attempts: The total number of attempts to make.  If `None`, the task will
                be retried indefinitely.
            minimum_delay: The minimum delay between attempts.
            maximum_delay: The maximum delay between attempts.
        r   N)superr[   r   )r)   r   r   r   	__class__s       r*   r[   zExponentialRetry.__init__A  s0     	(-@@@*r,   c                   K   | j                                         }t          | j        | j        | j                  }|j        |_        |j        dk    r6d|j        dz
  z  }| j        |z  }|| j        k    r| j        |_        n||_        |S )N)r   r   r   r      )r#   r>   r   r   r   r   r   )r)   r#   r   backoff_factorcalculated_delays        r*   r+   zExponentialRetry.__aenter__Q  s      N&&((	 ]*,
 
 

 ")q  9#4q#89N#zN:$"444"0.r,   )r$   r   )	r2   r3   r4   r   r   r   r[   r+   __classcell__)r   s   @r*   r   r   3  s           !#,9Q#7#7#7#,9R#8#8#8	+ +*+ !+ !	+
 
+ + + + + +        r,   r   c                       e Zd ZU dZdZeed<   eed<   ee	df         ed<   e
ee	f         ed<   eed<    ed	          d
fdededdfdZddZddZde	de	ddfdZdS )	Perpetualay  Declare a task that should be run perpetually.  Perpetual tasks are automatically
    rescheduled for the future after they finish (whether they succeed or fail).  A
    perpetual task can be scheduled at worker startup with the `automatic=True`.

    Example:

    ```python
    @task
    async def my_task(perpetual: Perpetual = Perpetual()) -> None:
        ...
    ```
    Tevery	automatic.argskwargs	cancelledr   Fr$   Nc                 0    || _         || _        d| _        dS )a  
        Args:
            every: The target interval between task executions.
            automatic: If set, this task will be automatically scheduled during worker
                startup and continually through the worker's lifespan.  This ensures
                that the task will always be scheduled despite crashes and other
                adverse conditions.  Automatic tasks must not require any arguments.
        FN)r   r   r   )r)   r   r   s      r*   r[   zPerpetual.__init__  s     
"r,   c                    K   | j                                         }t          | j                  }|j        |_        |j        |_        |S )N)r   )r#   r>   r   r   r   r   )r)   r#   	perpetuals      r*   r+   zPerpetual.__aenter__  sE      N&&((	DJ///	"	$+	r,   c                     d| _         d S )NT)r   r(   s    r*   cancelzPerpetual.cancel  s    r,   c                 "    || _         || _        d S r&   )r   r   )r)   r   r   s      r*   
perpetuatezPerpetual.perpetuate  s    	r,   )r$   r   r   )r2   r3   r4   r   r    r   r6   r5   tupler   dictrR   r[   r+   r   r   r'   r,   r*   r   r   g  s          FOOO
S/cNOOO %9Q<<   
	   "       s t      r,   r   c                       e Zd ZU dZdZeed<   eed<   eed<   deddfdZ	dd	Z
dd
ZdefdZdefdZddedz  ddfdZdS )Timeoutac  Configures a timeout for a task.  You can specify the base timeout, and the
    task will be cancelled if it exceeds this duration.  The timeout may be extended
    within the context of a single running task.

    Example:

    ```python
    @task
    async def my_task(timeout: Timeout = Timeout(timedelta(seconds=10))) -> None:
        ...
    ```
    Tr    base	_deadliner$   Nc                     || _         dS )zD
        Args:
            base: The base timeout duration.
        Nr   )r)   r   s     r*   r[   zTimeout.__init__  s    
 			r,   c                 \   K   t          | j                  }|                                 |S )Nr   )r   r   start)r)   timeouts     r*   r+   zTimeout.__aenter__  s*      ty)))r,   c                 j    t          j                    | j                                        z   | _        d S r&   )time	monotonicr   r   r   r(   s    r*   r   zTimeout.start  s(    ))DI,C,C,E,EEr,   c                 :    t          j                    | j        k    S r&   )r   r   r   r(   s    r*   expiredzTimeout.expired  s    ~4>11r,   c                 T    t          | j        t          j                    z
            S )z1Get the remaining time until the timeout expires.r   )r   r   r   r   r(   s    r*   	remainingzTimeout.remaining  s"    $.2B2B!BCCCCr,   byc                 \    || j         }| xj        |                                z  c_        dS )zExtend the timeout by a given duration.  If no duration is provided, the
        base timeout will be used.

        Args:
            by: The duration to extend the timeout by.
        N)r   r   r   )r)   r   s     r*   extendzTimeout.extend  s0     :B"**,,,r,   )r$   r   r   r&   )r2   r3   r4   r   r    r5   r6   r   floatr[   r+   r   r   r   r   r'   r,   r*   r   r     s           FD
OOOY 4       
F F F F2 2 2 2 2D9 D D D D	- 	-T) 	-T 	- 	- 	- 	- 	- 	-r,   r   R._parameter_cacheri   c                    | t           v r6t          j        t          t                     ddi           t           |          S i }t	          |           }|j                                        D ]*\  }}t          |j        t                    s |j        ||<   +|t           | <   t          j        t          t                     ddi           |S )NcacherW   )
r   r   setlenr   
parametersitems
isinstancedefaultr   )ri   dependencies	signaturerW   params        r*   get_dependency_parametersr     s     ###s+,,w.DEEE))*,Lh''I%06688 0 0	5%-44 	"'-Y!-XN3'((7K*@AAAr,   c                   .   e Zd ZU ee         ed<    ed          Zeeee	         e	f                  ed<    ed          Z
ee         ed<   deg eee         z  ee         z  ee         z  f         ddfdZdeee	         z  deee	f         fdZdefd	ZdS )
_Depends
dependencyr   stackr$   Nc                     || _         d S r&   r   )r)   r   s     r*   r[   z_Depends.__init__  s     %r,   ri   c                   K   | j                                         }i }t          |          }|                                D ]F\  }}t	          |t
                    r|j        s||_        |                    |           d {V ||<   G|S r&   )r   r>   r   r   r   rV   rW   enter_async_context)r)   ri   r   	argumentsr   rW   r   s          r*   _resolve_parametersz_Depends._resolve_parameters  s       
  $&	.x88
%/%5%5%7%7 	O 	O!Iz *m44 1Z=Q 1'0
$).)B)B:)N)N#N#N#N#N#N#NIi  r,   c                   K   | j                                         }| j        |v r|| j                 S | j                                        }|                     | j                   d {V } | j        di |}t          |t                    r|                    |           d {V }nt          |t                    r|	                    |          }net          j        |          st          |t                    r't          t          t                   |           d {V }nt          t          |          }||| j        <   |S )Nr'   )r   r>   r   r   r   r   r   r   r   enter_contextinspectiscoroutiner   r   r   )r)   r   r   r   	raw_valueresolved_values         r*   r+   z_Depends.__aenter__  sV     
  ?e##))
  224?CCCCCCCC	 DO((i(( 	 i!455 	0#(#<#<Y#G#GGGGGGGNN	>22 	0"00;;NN ++ 	0z)Y/O/O 	0#'	!i#@#@@@@@@@NN "!Y//N!/dor,   )r2   r3   r4   DependencyFunctionr   r6   r   r   r   r   r   r   r   r   r   r   r[   r   rR   r   r+   r'   r,   r*   r   r     s        "1%%%%<FJw<O<OE:d-c2C789OOO(2
7(;(;E:n%;;;%IaL >!#447J17MMM
%
 
% % % %!3C!88 
c3h   &!      r,   r   r   c                 F    t          t          t          |                     S )a,  Include a user-defined function as a dependency.  Dependencies may be:
    - Synchronous functions returning a value
    - Asynchronous functions returning a value (awaitable)
    - Synchronous context managers (using @contextmanager)
    - Asynchronous context managers (using @asynccontextmanager)

    If a dependency returns a context manager, it will be entered and exited around
    the task, giving an opportunity to control the lifetime of a resource.

    **Important**: Synchronous dependencies should NOT include blocking I/O operations
    (file access, network calls, database queries, etc.). Use async dependencies for
    any I/O. Sync dependencies are best for:
    - Pure computations
    - In-memory data structure access
    - Configuration lookups from memory
    - Non-blocking transformations

    Examples:

    ```python
    # Sync dependency - pure computation, no I/O
    def get_config() -> dict:
        # Access in-memory config, no I/O
        return {"api_url": "https://api.example.com", "timeout": 30}

    # Sync dependency - compute value from arguments
    def build_query_params(
        user_id: int = TaskArgument(),
        config: dict = Depends(get_config)
    ) -> dict:
        # Pure computation, no I/O
        return {"user_id": user_id, "timeout": config["timeout"]}

    # Async dependency - I/O operations
    async def get_user(user_id: int = TaskArgument()) -> User:
        # Network I/O - must be async
        return await fetch_user_from_api(user_id)

    # Async context manager - I/O resource management
    from contextlib import asynccontextmanager

    @asynccontextmanager
    async def get_db_connection():
        # I/O operations - must be async
        conn = await db.connect()
        try:
            yield conn
        finally:
            await conn.close()

    @task
    async def my_task(
        params: dict = Depends(build_query_params),
        user: User = Depends(get_user),
        db: Connection = Depends(get_db_connection),
    ) -> None:
        await db.execute("UPDATE users SET ...", params)
    ```
    )r   r   r   r   s    r*   Dependsr   8  s    x 8J''(((r,   c            	           e Zd ZU dZdZeed<   	 ddedededz  d	dfd
Z	ddZ
ed	edz  fd            Zed	efd            ZdS )ConcurrencyLimita  Configures concurrency limits for a task based on specific argument values.

    This allows fine-grained control over task execution by limiting concurrent
    tasks based on the value of specific arguments.

    Example:

    ```python
    async def process_customer(
        customer_id: int,
        concurrency: ConcurrencyLimit = ConcurrencyLimit("customer_id", max_concurrent=1)
    ) -> None:
        # Only one task per customer_id will run at a time
        ...

    async def backup_db(
        db_name: str,
        concurrency: ConcurrencyLimit = ConcurrencyLimit("db_name", max_concurrent=3)
    ) -> None:
        # Only 3 backup tasks per database name will run at a time
        ...
    ```
    Tr    r   Nargument_namemax_concurrentscoper$   c                 L    || _         || _        || _        d| _        d| _        dS )a  
        Args:
            argument_name: The name of the task argument to use for concurrency grouping
            max_concurrent: Maximum number of concurrent tasks per unique argument value
            scope: Optional scope prefix for Redis keys (defaults to docket name)
        NF)r   r   r   _concurrency_key_initialized)r)   r   r   r   s       r*   r[   zConcurrencyLimit.__init__  s1     +,
,0"'r,   c                   K   | j                                         }| j                                        }	 |                    | j                  }n@# t
          $ r3 t          | j        | j        | j                  }d |_	        d|_
        |cY S w xY w| j        p|j        }| d| j         d| | _	        t          | j        | j        | j                  }| j	        |_	        d|_
        |S )NTz:concurrency::)r#   r>   r!   r]   r   r^   r   r   r   r   r   name)r)   r#   r!   argument_valuelimitr   s         r*   r+   zConcurrencyLimit.__aenter__  s     N&&((	""		&33D4FGGNN 	 	 	$"D$7 E &*E"!%ELLL	 
)fkHH4#5HHHH 	 !!3T5H$*UU!%!6!s   A :BBc                 <    | j         st          d          | j        S )zRedis key used for tracking concurrency for this specific argument value.
        Returns None when concurrency control is bypassed due to missing arguments.
        Raises RuntimeError if accessed before initialization.z:ConcurrencyLimit not initialized - use within task context)r   RuntimeErrorr   r(   s    r*   concurrency_keyz ConcurrencyLimit.concurrency_key  s/    
   	L   $$r,   c                 "    | j         o| j        du S )zIReturns True if concurrency control is bypassed due to missing arguments.N)r   r   r(   s    r*   is_bypassedzConcurrencyLimit.is_bypassed  s      BT%:d%BBr,   )r   N)r$   r   )r2   r3   r4   r   r    r5   r6   rR   r   r[   r+   r   r  r  r'   r,   r*   r   r   w  s          0 FD PT( ( (25(BE*(	( ( ( (   6 %t % % % X% CT C C C XC C Cr,   r   D)bounddependency_typec                     |j         s
J d            t          |                                           D ]\  }}t          ||          r|c S d S NzDependency must be single)r    r   r   r   )ri   r  _r   s       r*   'get_single_dependency_parameter_of_typer
    sk     !>>#>>>>28<<BBDD  :j/22 		4r,   r   c                     |j         s
J d            |                                 D ]\  }}t          ||          r|c S d S r  )r    r   r   )r   r  r	  r   s       r*   get_single_dependency_of_typer    sc     !>>#>>>>%++--  :j/22 		4r,   c                     t          |           }t          d |                                D                       }|                                D ]*\  }}|j        r|dk    rt          d|j         d          +d S )Nc              3   4   K   | ]}t          |          V  d S r&   )r9   ).0r   s     r*   	<genexpr>z(validate_dependencies.<locals>.<genexpr>  s*      LL*T*%%LLLLLLr,   r   z	Only one z dependency is allowed per task)r   r   valuesr   r    
ValueErrorr2   )ri   r   countsr  counts        r*   validate_dependenciesr    s    *844JLL
8I8I8K8KLLLLLF"(,,..  ! 	eaiiUO4UUU   r,   c                   "    e Zd ZdededdfdZdS )FailedDependencyrW   errorr$   Nc                 "    || _         || _        d S r&   )rW   r  )r)   rW   r  s      r*   r[   zFailedDependency.__init__  s    "


r,   )r2   r3   r4   rR   	Exceptionr[   r'   r,   r*   r  r    s=        # i D      r,   r  r"   r#   c                  K   t           j                            | j                  }t           j                            |           }t           j                            |          }t
          j                            i           }	 t                      4 d {V }t
          j                            |          }	 i }t          |j
                  }	|	                                D ]\  }
}|j        }|
|v r||
         ||
<   t          |t                    r(|j        s!t!          |
t#          d                    ||
<   Y	 |                    |           d {V ||
<   y# t&          $ r}t!          |
|          ||
<   Y d }~d }~ww xY w|W V  t
          j                            |           n$# t
          j                            |           w xY w	 d d d           d {V  n# 1 d {V swxY w Y   t
          j                            |           t           j                            |           t           j                            |           t           j                            |           d S # t
          j                            |           t           j                            |           t           j                            |           t           j                            |           w xY w)NzNo parameter name specified)r   r!   r   r"   r#   r   r   r   r   r   ri   r   r   r   rV   rW   r  r  r   r  reset)r"   r#   docket_tokenworker_tokenexecution_tokencache_tokenr   stack_tokenr   r   rW   r   r   r  s                 r*   resolved_dependenciesr"    sw     
 $((77L$((00L *..y99O.$$R((K(.!## "	2 "	2 "	2 "	2 "	2 "	2 "	2u".,,U33K 2,.	6y7IJJ
-7-=-=-?-? R R)Iz&-F F**/5i/@	),  #:}==! * 4! 0@%z2O'P'P0 0	), !R5:5N5N&6 6 0 0 0 0 0 0	),, % R R R/?	5/Q/Q	),,,,,,R  $$[1111$$[11111E"	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2 "	2H 	[)))""?333-------- 	[)))""?333-------st   I2  G#:BF,>EF,
F'E?:F,?FF, G#,!GG#I2 #
G--I2 0G-1I2 2A>K0r@   r`   rn   )Mr7   r   rg   r   
contextlibr   r   contextvarsr   r   r   r   typesr	   typingr
   r   r   r   r   r   r   r   r   r   r   r   r!   r   r#   r   r   r   r   instrumentationr   r"   r   ABCr   r<   rC   rE   rH   rJ   rM   rO   rR   rT   rV   r5   rb   rd   rp   rr   r  r   r   r   r   r   r   r   r   r   r6   r   r   r   r   r  r9   r
  r  r  r  r"  r'   r,   r*   <module>r)     s   




    : : : : : : : : " " " " " " 2 2 2 2 2 2 2 2 2 2                                        P P P P P P P P P P P P ' ' ' ' ' '         $! ! ! ! !Z ! ! !
, , , ,! ! ! ! !Z ! ! !
*v * * * *$ $ $ $ $
 $ $ $
0) 0 0 0 0( ( ( ( (z ( ( (
! ! ! ! !    J   &9 9C$J 9 9# 9 9 9 9(
 
 
 
 
* 
 
 
H H H H :2 :2 :2 :2 :2z :2 :2 :2z@ @ @ @ @) @ @ @+ + + + +J + + +\1 1 1 1 1u 1 1 1h5 5 5 5 5
 5 5 5p2- 2- 2- 2- 2-j 2- 2- 2-j GCLLYq\	N1-	-0CA0F	FF   $%c**j   /44	#z/   ,> > > > >z71: > > >B<)*1- <)! <) <) <) <)~SC SC SC SC SCz SC SC SCl GCz"""-1!WX   sJ':>q'X   	L 	T 	 	 	 	        1.1.!*1.DcND()1. 1. 1. 1. 1. 1.r,   