o
    h(                     @   s   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
 zd dlZd dlmZ W n ey7   edw d dlmZmZ erTd dlmZ d d	lmZ d d
lmZ dd Zdd Zdd ZG dd deZdS )    N)OP)IntegrationDidNotEnable)event_from_exceptionloggerreraise)Taskzasyncio not available)castTYPE_CHECKING)Any)	Coroutine)ExcInfoc                 C   s   t | dd pt | dd pdS )N__qualname____name__zcoroutine without __name__)getattrcoro r   a/var/www/html/pro-man-master/venv/lib/python3.10/site-packages/sentry_sdk/integrations/asyncio.pyget_name   s
   
r   c                     sP   d  zt  } |    fdd}| | W d S  ty'   td Y d S w )Nc                    s    fdd}d }r| | fi |}|d u r*t | fd| i|}|jr*|jd= ztd|t  d W |S  tyD   Y |S w )Nc                     s   d } t  Q t jtjt tjd, z I d H } W n ty+ } z|d d }~w t	y8   t
t   Y nw W d    n1 sCw   Y  W d    | S W d    | S 1 s[w   Y  | S )N)opnameorigin)
sentry_sdkisolation_scope
start_spanr   FUNCTIONr   AsyncioIntegrationr   StopAsyncIteration	Exceptionr   _capture_exception)resulter   r   r   _task_with_sentry_span_creation*   s2   


zTpatch_asyncio.<locals>._sentry_task_factory.<locals>._task_with_sentry_span_creationloopzasyncio.Task[Any]z (Sentry-wrapped))r   _source_tracebackr	   set_namer   AttributeError)r$   r   kwargsr#   taskorig_task_factoryr   r   _sentry_task_factory'   s*   
z+patch_asyncio.<locals>._sentry_task_factoryzThere 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$   r-   r   r+   r   patch_asyncio    s   5
r4   c                  C   sN   t  } t }|t}|d ur%t| |jdddd\}}tj||d | S )Nr.   F)typehandled)client_options	mechanism)hint)	sysexc_infor   
get_clientget_integrationr   r   optionscapture_event)r;   clientintegrationeventr9   r   r   r   r    h   s   

r    c                   @   s&   e Zd ZdZde Zedd ZdS )r   r.   zauto.function.c                   C   s
   t   d S )N)r4   r   r   r   r   
setup_once~   s   
zAsyncioIntegration.setup_onceN)r   
__module__r   
identifierr   staticmethodrC   r   r   r   r   r   z   s
    
r   )r:   r   sentry_sdk.constsr   sentry_sdk.integrationsr   r   sentry_sdk.utilsr   r   r   r.   asyncio.tasksr   ImportErrortypingr	   r
   r   collections.abcr   sentry_sdk._typesr   r   r4   r    r   r   r   r   r   <module>   s(    	H