o
    hy                     @   s   d dl m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 d dlmZ d dlmZ d d	lmZmZ erbd d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ ededef dZG dd deZdd Zdd ZdS )    )absolute_importNwraps)Threadcurrent_thread)Hub)reraise)TYPE_CHECKING)Integration)event_from_exceptioncapture_internal_exceptions)Any)TypeVar)Callable)Optional)ExcInfoF.)boundc                   @   s&   e Zd ZdZdddZedd ZdS )	ThreadingIntegration	threadingFc                 C   s
   || _ d S N)propagate_hub)selfr    r   d/var/www/html/aiguide_backend/venv/lib/python3.10/site-packages/sentry_sdk/integrations/threading.py__init__   s   
zThreadingIntegration.__init__c                     s$   t j t  fdd} | t _d S )Nc                    s   t j}|t}|d ur7|jsd }nt |}t  t|t| jd| j}|| _W d    n1 s2w   Y   | g|R i |S )N__func__)	r   currentget_integrationr   r   r   	_wrap_rungetattrrun)r   akwhubintegrationhub_new_run	old_startr   r   sentry_start$   s   
z5ThreadingIntegration.setup_once.<locals>.sentry_start)r   startr   )r*   r   r(   r   
setup_once   s   
zThreadingIntegration.setup_onceN)F)__name__
__module____qualname__
identifierr   staticmethodr,   r   r   r   r   r      s
    
r   c                    s   t   fdd}|S )Nc               	      s~   pt j}|. zt } |g| R i |W W  d    S  ty,   tt   Y nw W d    d S 1 s8w   Y  d S r   )r   r   r   	Exceptionr   _capture_exception)r"   r#   r$   r   old_run_func
parent_hubr   r   r!   ?   s   
"z_wrap_run.<locals>.runr   )r6   r5   r!   r   r4   r   r   =   s   
r   c                  C   sN   t j} t }| td ur%| j}t||jdddd\}}| j	||d |S )Nr   F)typehandled)client_options	mechanism)hint)
r   r   sysexc_infor   r   clientr   optionscapture_event)r$   r=   r>   eventr;   r   r   r   r3   M   s   
r3   )
__future__r   r<   	functoolsr   r   r   r   
sentry_sdkr   sentry_sdk._compatr   sentry_sdk._typesr	   sentry_sdk.integrationsr
   sentry_sdk.utilsr   r   typingr   r   r   r   r   r   r   r   r3   r   r   r   r   <module>   s&    %