
    tni                     <   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	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S )    N)OP)IntegrationDidNotEnable)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    \/var/www/html/gpu-tools/venv/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                    } |                                 	 	 	 	 	 	 	 	 dfd	}|                     |           d S # t          $ r t          j        d
           Y d S w xY w)N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                    5  t          j        t          j        t                    t          j                  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 )N)opnameorigin)
sentry_sdkisolation_scope
start_spanr   FUNCTIONr   AsyncioIntegrationr0   StopAsyncIteration	Exceptionr   _capture_exception)resulter   s     r   _task_with_sentry_span_creationzTpatch_asyncio.<locals>._sentry_task_factory.<locals>._task_with_sentry_span_creation7   sa     /11 ; ;#.;%d^^18   
; 
;
;+/ZZZZZZFF1 . . ."#-( ; ; ;#%7%9%9::::;
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; se   9B5BAB
B'A**"BBBBB5B"	"B5%B"	&B55B9<B9r(   zasyncio.Task[Any]z (Sentry-wrapped))r   r   )r&   r	   _source_tracebackr
   set_namer   AttributeError)r(   r   r*   r;   taskorig_task_factorys    `   r   _sentry_task_factoryz+patch_asyncio.<locals>._sentry_task_factory2   s!   
 T""     #"$ D ! ((99;; ?E  | ;;==SSDSFSS) 3.r2($//88~~888    "    Ks   3B 
BBzThere 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_factoryset_task_factoryRuntimeErrorr   warning)r(   rB   rA   s     @r   patch_asynciorI   ,   s    D
')) 11335	-5	,5	 5	 #	5	 5	 5	 5	 5	 5	n 	233333 
 
 
P	
 	
 	
 	
 	
 	

s   A
A A32A3r   c                      t          j                    } t          j                    }|                    t
                    }|3t          | |j        ddd          \  }}t          j        ||           | S )NrC   F)typehandled)client_options	mechanism)hint)	sysexc_infor1   
get_clientget_integrationr5   r   optionscapture_event)rQ   clientintegrationeventrO   s        r   r8   r8   u   s}    |~~H"$$F(();<<K*!>(U;;
 
 
t
 	 T2222Or   c                   4    e Zd ZdZde Zedd            ZdS )r5   rC   zauto.function.r   Nc                  "    t                       d S )N)rI   r    r   r   
setup_oncezAsyncioIntegration.setup_once   s    r   r   N)r   
__module__r   
identifierr0   staticmethodr[   r    r   r   r5   r5      sD        J*j**F   \  r   r5   )r   r   r   r   r\   )r   r   )!rP   r#   r1   sentry_sdk.constsr   sentry_sdk.integrationsr   r   sentry_sdk.utilsr   r   r   rC   asyncio.tasksr	   ImportErrortypingr
   r   r   r   r   collections.abcr   sentry_sdk._typesr   r   strr   r&   rI   r8   r5   r    r   r   <module>ri      s   



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