
    Dj                         d dl Z d dlmZ d dlmZm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mZ d dlmZ er-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  ededef         Z G d de      Zd Zd Zy)    Nwraps)Threadcurrent_thread)Integrationuse_isolation_scope	use_scope)event_from_exceptioncapture_internal_exceptionsloggerreraise)TYPE_CHECKING)Any)TypeVar)Callable)Optional)ExcInfoF.)boundc                   (    e Zd ZdZddZed        Zy)ThreadingIntegration	threadingNc                 T    |t        j                  d       || _        ||| _        y y )NzLDeprecated: propagate_hub is deprecated. This will be removed in the future.)r   warningpropagate_scope)selfpropagate_hubr   s      eC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\sentry_sdk/integrations/threading.py__init__zThreadingIntegration.__init__   s4    $NN^  /$#0D  %    c                  b    t         j                  t              fd       } | t         _        y )Nc           
         t        j                         j                  t              }| | g|i |S |j                  r)t        j
                         }t        j                         }nd }d }t               5  t        ||t        | j                  d| j                              }|| _
        d d d         | g|i |S # 1 sw Y   xY w)N__func__)
sentry_sdk
get_clientget_integrationr   r   get_isolation_scopeget_current_scoper   	_wrap_rungetattrrun)r   akwintegrationisolation_scopecurrent_scopenew_run	old_starts          r   sentry_startz5ThreadingIntegration.setup_once.<locals>.sentry_start4   s     %//1AABVWK" 00R00**","@"@"B * < < >"& $ -. ###!DHHj$((;
 ## T,A,,,# #s   :4CC)r   startr   )r4   r3   s    @r   
setup_oncezThreadingIntegration.setup_once/   s.     LL		y		- 
	-: $r!   )NT)__name__
__module____qualname__
identifierr    staticmethodr6    r!   r   r   r      s     J1  "$ "$r!   r   c                 6     t               fd       }|S )Nc                        fd}31t              5  t              5   |       cd d d        cd d d        S  |       S # 1 sw Y   nxY w	 d d d        y # 1 sw Y   y xY w)Nc                  p    	 t               }  | gi S # t        $ r t        t                 Y y w xY w)N)r   	Exceptionr   _capture_exception)r   r-   r.   old_run_funcs    r   _run_old_run_funcz1_wrap_run.<locals>.run.<locals>._run_old_run_funcZ   s@    /%'#D31333 /+-./s    55r   )r-   r.   rC   current_scope_to_useisolation_scope_to_userB   s   `` r   r,   z_wrap_run.<locals>.runW   sw    	/ "-2F2R$%;< /34 /,./ // / %&&/ / // / /s!   AA	AA	AA&r   )rE   rD   rB   r,   s   ``` r   r*   r*   U   s!    
<' '" Jr!   c                      t        j                         } t        j                         }|j	                  t
              5t        | |j                  ddd      \  }}t        j                  ||       | S )Nr   F)typehandled)client_options	mechanism)hint)	sysexc_infor%   r&   r'   r   r   optionscapture_event)rM   clienteventrK   s       r   rA   rA   l   sd    ||~H""$F23?*!>>*u=
t
 	  T2Or!   )rL   	functoolsr   r   r   r   r%   sentry_sdk.integrationsr   sentry_sdk.scoper	   r
   sentry_sdk.utilsr   r   r   r   typingr   r   r   r   r   sentry_sdk._typesr   r   r   r*   rA   r<   r!   r   <module>rX      sd    
  ,  / ;  !)8CH-.A6$; 6$r.r!   