
    `iR                     P   d dl Z d dlZd dlZd dlm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Zd dlmZ n# e$ r  ed          w xY wd dlmZmZ er+d d	lmZmZmZ d d
lmZ d dlmZ  ededef                   ZdddefdZddZd dZ d!dZ! G d de          Z"d"dZ#dS )#    N)OP)IntegrationDidNotEnable)nullcontext)event_from_exceptionloggerreraise)Taskzasyncio not available)castTYPE_CHECKING)AnyCallableTypeVar)	Coroutine)ExcInfoT.)boundcoror   returnc                 J    t          | dd           pt          | dd           pdS )N__qualname____name__zcoroutine without __name__)getattr)r   s    s/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/sentry_sdk/integrations/asyncio.pyget_namer      s2    nd++ 	(4T**	('    wrappedCoroutine[Any, Any, Any]Callable[[T], T]c                 F    t          j        t           j        | dd          S )N)r   r    )r   assignedupdated)	functoolspartialupdate_wrapper)r   s    r   _wrap_coroutiner'   #   s+     -	   r   c                      d 	 t          j                    } |                                 t          dd          rd S 	 	 	 	 	 	 	 	 dfd}d|_        |                     |           d S # t          $ r t          j        d           Y d S w xY w)N_is_sentry_task_factoryFloopasyncio.AbstractEventLoopr   r   kwargsr   r   asyncio.Future[Any]c                 F   t                    dfd            }d }r |  |            fi |}|&t           |            fd| i|}|j        r|j        d= 	 t          d|                              t                     d           n# t          $ r Y nw xY w|S )	Nr   r   c                    K   d } t          j                                        t                    }|r|j        nd}t          j                    5  |r8t          j        t          j        t                    t          j
                  nt                      5  	  d {V } n5# t          $ r}|d d }~wt          $ r t          t                        Y nw xY wd d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   | S )NF)opnameorigin)
sentry_sdk
get_clientget_integrationAsyncioIntegration
task_spansisolation_scope
start_spanr   FUNCTIONr   r2   r   StopAsyncIteration	Exceptionr	   _capture_exception)resultintegrationr7   er   s       r   _task_with_sentry_span_creationzTpatch_asyncio.<locals>._sentry_task_factory.<locals>._task_with_sentry_span_creation<   s     (355EE&  8CM[33
/11 ; ; &+
-!{!)$#5#<    )]]; ;;+/ZZZZZZFF1 . . ."#-( ; ; ;#%7%9%9::::;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;" sg   A	C;C$B#"C$#
C-B00"CC$CC$C;$C(	(C;+C(	,C;;C?C?r*   zasyncio.Task[Any]z (Sentry-wrapped))r   r   )r'   r
   _source_tracebackr   set_namer   AttributeError)r*   r   r,   rA   taskorig_task_factorys    `   r   _sentry_task_factoryz+patch_asyncio.<locals>._sentry_task_factory7   s!   
 T""     #"6 D ! ((99;; ?E  | ;;==SSDSFSS) 3.r2($//88~~888    "    Ks   3B 
BBTzThere is no running asyncio loop so there is nothing Sentry can patch. Please make sure you call sentry_sdk.init() within a running asyncio loop for the AsyncioIntegration to work. See https://docs.sentry.io/platforms/python/integrations/asyncio/)r*   r+   r   r   r,   r   r   r-   )	asyncioget_running_loopget_task_factoryr   r)   set_task_factoryRuntimeErrorr   warning)r*   rH   rG   s     @r   patch_asynciorO   -   s    R
')) 1133 $&?GG 	F>	->	,>	 >	 #	>	 >	 >	 >	 >	 >	@ 8<4233333 
 
 
P	
 	
 	
 	
 	
 	

s   8A+ *A+ +BBr   c                      t          j                    } t          j                    }|                    t
                    }|3t          | |j        ddd          \  }}t          j        ||           | S )NrI   F)typehandled)client_options	mechanism)hint)	sysexc_infor3   r4   r5   r6   r   optionscapture_event)rW   clientr?   eventrU   s        r   r=   r=      s}    |~~H"$$F(();<<K*!>(U;;
 
 
t
 	 T2222Or   c                   F    e Zd ZdZde Zd	deddfdZed
d            ZdS )r6   rI   zauto.function.Tr7   r   Nc                     || _         d S N)r7   )selfr7   s     r   __init__zAsyncioIntegration.__init__   s    $r   c                  "    t                       d S r^   )rO   r!   r   r   
setup_oncezAsyncioIntegration.setup_once   s    r   )Tr   N)	r   
__module__r   
identifierr2   boolr`   staticmethodrb   r!   r   r   r6   r6      sm        J*j**F% %4 %4 % % % %    \  r   r6   argsr,   c                      t          j                    }|                                sdS t          j        d           t          | i |}|                                 d|j        vr||j        d<   dS dS )a  
    Enable AsyncioIntegration with the provided options.

    This is useful in scenarios where Sentry needs to be initialized before
    an event loop is set up, but you still want to instrument asyncio once there
    is an event loop. In that case, you can sentry_sdk.init() early on without
    the AsyncioIntegration and then, once the event loop has been set up,
    execute:

    ```python
    from sentry_sdk.integrations.asyncio import enable_asyncio_integration

    async def async_entrypoint():
        enable_asyncio_integration()
    ```

    Any arguments provided will be passed to AsyncioIntegration() as is.

    If AsyncioIntegration has already patched the current event loop, this
    function won't have any effect.

    If AsyncioIntegration was provided in
    sentry_sdk.init(disabled_integrations=[...]), this function will ignore that
    and the integration will be enabled.
    NzSetting up integration asynciorI   )r3   r4   	is_activer   debugr6   rb   integrations)rh   r,   rZ   r?   s       r   enable_asyncio_integrationrm      s    4 "$$F  L1222$d5f55K+++)4I&&& ,+r   )r   r   r   r   rc   )r   r   )rh   r   r,   r   r   N)$rV   r$   r3   sentry_sdk.constsr   sentry_sdk.integrationsr   r   $sentry_sdk.integrations._wsgi_commonr   sentry_sdk.utilsr   r   r	   rI   asyncio.tasksr
   ImportErrortypingr   r   r   r   r   collections.abcr   sentry_sdk._typesr   r   strr   r'   rO   r=   r6   rm   r!   r   r   <module>rx      s   



                     = = = = = = = = < < < < < < B B B B B B B B B B0NNN""""""" 0 0 0
,.
/
//0 ' & & & & & & & /----------))))))))))))8CH-...A5 S       T
 T
 T
 T
n   "	 	 	 	 	 	 	 	*5 *5 *5 *5 *5 *5s	   
7 A