
    i(                         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 d dlmZmZ erd dlmZ d d	lmZ d d
lmZ d Zd Zd Z G d de      Zy# e$ r	  ed      w xY w)    N)OP)IntegrationDidNotEnable)event_from_exceptionloggerreraise)Taskzasyncio not available)castTYPE_CHECKING)Any)	Coroutine)ExcInfoc                 B    t        | dd       xs t        | dd       xs dS )N__qualname____name__zcoroutine without __name__)getattr)coros    /var/www/html/hwPaymentPortal-be-dev/hw-payment-portal-api/venv/lib/python3.12/site-packages/sentry_sdk/integrations/asyncio.pyget_namer      s.     	nd+ 	(4T*	('    c                      d 	 t        j                         } | j                         fd}| j                  |       y # t        $ r t        j                  d       Y y w xY w)Nc                    fd}d }r |  |       fi |}|,t         |       fd| i|}|j                  r|j                  d= 	 t        d|      j                  t	               d       |S # t
        $ r Y |S w xY w)Nc                    K   d } t        j                         5  t        j                  t        j                  t              t        j                        5  	  d {   } d d d        d d d        | S 7 # t        $ r}|d d }~wt        $ r t        t                 Y >w xY w# 1 sw Y   CxY w# 1 sw Y   | S xY ww)N)opnameorigin)
sentry_sdkisolation_scope
start_spanr   FUNCTIONr   AsyncioIntegrationr   StopAsyncIteration	Exceptionr   _capture_exception)resulter   s     r   _task_with_sentry_span_creationzTpatch_asyncio.<locals>._sentry_task_factory.<locals>._task_with_sentry_span_creation*   s     //1 ;#..;;%d^188 
;
;+/ZF
;;  &01 ."#-( ;#%7%9:;
; 
;; sp   B?>B2B&A8A6 A8$B2,
B?6A88	B#BB# B&"B##B&&B/	+B22B<7B?loopzasyncio.Task[Any]z (Sentry-wrapped))r	   _source_tracebackr
   set_namer   AttributeError)r(   r   kwargsr'   taskorig_task_factorys    `   r   _sentry_task_factoryz+patch_asyncio.<locals>._sentry_task_factory'   s    & D !(9;?E | ;=SDSFS))..r2($/88~&&78 K	 " K	s   
'A3 3	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/)asyncioget_running_loopget_task_factoryset_task_factoryRuntimeErrorr   warning)r(   r0   r/   s     @r   patch_asyncior7       sd    B
'') 1133	j 	23 
P	

s   :A   A! A!c                      t        j                         } t        j                         }|j	                  t
              }|5t        | |j                  ddd      \  }}t        j                  ||       | S )Nr1   F)typehandled)client_options	mechanism)hint)	sysexc_infor   
get_clientget_integrationr!   r   optionscapture_event)r?   clientintegrationeventr=   s        r   r$   r$   h   si    ||~H""$F(();<K*!>>(U;
t
 	  T2Or   c                   *    e Zd ZdZde Zed        Zy)r!   r1   zauto.function.c                      t                y )N)r7    r   r   
setup_oncezAsyncioIntegration.setup_once~   s	     	r   N)r   
__module__r   
identifierr   staticmethodrJ   rI   r   r   r!   r!   z   s%    Jj\*F r   r!   )r>   r   sentry_sdk.constsr   sentry_sdk.integrationsr   r   sentry_sdk.utilsr   r   r   r1   asyncio.tasksr	   ImportErrortypingr
   r   r   collections.abcr   sentry_sdk._typesr   r   r7   r$   r!   rI   r   r   <module>rV      sn    
    = B B0" '))E
P$ _  0
.
//0s   
A A+