
    Ji                        % S SK Jr  S SKJrJr  S SKJrJrJr  S SK	J
r
  \
" SSS9rS\S	'    " S
 S5      r " S S5      rg)    )annotations)CallableOptional)Executoras_completedFuture)
ContextVarasync_compile_active_modeN)defaultz&ContextVar[Optional[AsyncCompileMode]]active_modec                  ,    \ rS rSrSS jrSSS jjrSrg)	FutureKernel	   c                *    Xl         S U l        X l        g N)finalize_compilekernelfuture)selfr   r   s      _/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/triton/runtime/_async_compile.py__init__FutureKernel.__init__   s     0    c                    U R                   b  U R                   $  U R                  R                  5       nU R	                  U5        X l         U$ ! [         a    U(       a   g e f = fr   )r   r   result	Exceptionr   )r   ignore_errorsr   s      r   r   FutureKernel.result   sa    ;;";;	[['')F 	f%  			s   A A#!A#)r   r   r   N)r   r   r   r   )F)r   bool)__name__
__module____qualname____firstlineno__r   r   __static_attributes__ r   r   r   r   	   s    
 r   r   c                  8    \ rS rSrSS.S
S jjrS rS rS rSrg	)AsyncCompileMode    F)r   c               8    Xl         X l        / U l        0 U l        g r   )executorr   raw_futuresfuture_kernels)r   r*   r   s      r   r   AsyncCompileMode.__init__"   s     * r   c                    U R                   R                  U5      nUb  U$ U R                  R                  U5      nXl        U R
                  R                  U5        [        X45      nXPR                   U'   U$ r   )r,   getr*   submit_keyr+   appendr   )r   key
compile_fnfinalize_fnr   future_kernels         r   r0   AsyncCompileMode.submit(   sn    $$((-M%%j1'$[9#0C r   c                p    [         R                  5       b  [        S5      e[         R                  U 5        U $ )Nz*Another AsyncCompileMode is already active)r   r/   RuntimeErrorset)r   s    r   	__enter__AsyncCompileMode.__enter__4   s,    ??(KLLr   c                    [        U R                  5       H5  nU R                  UR                     R	                  U R
                  5        M7     [        R                  S 5        g r   )r   r+   r,   r1   r   r   r   r:   )r   exc_type	exc_value	tracebackr   s        r   __exit__AsyncCompileMode.__exit__:   sF    "4#3#34F,33D4F4FG 5r   )r*   r,   r   r+   N)r*   r   )	r    r!   r"   r#   r   r0   r;   rA   r$   r%   r   r   r'   r'       s    <A !
r   r'   )
__future__r   typingr   r   concurrent.futuresr   r   r   contextvarsr	   r   __annotations__r   r'   r%   r   r   <module>rH      s<    " % = = "6@A\fj6k3 k . r   