§
    xÅj[%  ã                   ó¤  — 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	 d dl
mZ d dlmZ d dlmZ d dlmZmZ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mZ er+d dlmZ d dlm Z m!Z!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*d)d!„Z+d+d#„Z, G d$„ d%e¦  «        Z-d,d'„Z.dS )-é    N)ÚOP)ÚDidNotEnableÚIntegration)ÚStreamedSpan)ÚSpan)Úhas_span_streaming_enabled)ÚAsyncHttpTransport)Úevent_from_exceptionÚis_internal_taskÚloggerÚnullcontextÚreraise)ÚTaskzasyncio not available)ÚTYPE_CHECKINGÚOptionalÚUnion)Ú	Coroutine)ÚAnyÚCallableÚTypeVar)Ú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    úPC:\Projects\Historical\venv\Lib\site-packages\sentry_sdk/integrations/asyncio.pyÚget_namer!   $   s2   € å��n dÑ+Ô+ð 	(Ý�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                  óÀ   ‡‡‡— 	 t          j        ¦   «         Šn# t          $ r Y dS w xY wt          ‰dd¦  «        rdS dd„Š‰j        Šdˆˆˆfd„} | ‰_        d‰_        dS )	z9Patch loop.close to flush pending events before shutdown.NÚ_sentry_flush_patchedFr   c               “   ó  K  — t          j        ¦   «         } |                      ¦   «         sd S 	 t          | j        t
          ¦  «        sd S |                      ¦   «         ƒ d {V —† d S # t          $ r t          j	        dd¬¦  «         Y d S w xY w)Nz(Sentry flush failed during loop shutdownT©Úexc_info)
Ú
sentry_sdkÚ
get_clientÚ	is_activeÚ
isinstanceÚ	transportr	   Úclose_asyncÚ	Exceptionr   Úwarning)Úclients    r    Ú_flushz patch_loop_close.<locals>._flushD   s·   è è € ÝÔ&Ñ(Ô(ˆØ×ÒÑ!Ô!ð 	ØˆFð	VÝ˜fÔ.Õ0BÑCÔCð Ø�à×$Ò$Ñ&Ô&Ð&Ð&Ð&Ð&Ð&Ð&Ð&Ð&Ð&øÝð 	Vð 	Vð 	VÝŒNÐEÐPTÐUÑUÔUÐUÐUÐUÐUð	Vøøøs   ­A% Á	A% Á% B	ÂB	c                  óÄ   •— 	 ‰                       ‰ ¦   «         ¦  «         n&# t          $ r t          j        dd¬¦  «         Y nw xY w ‰¦   «          d S #  ‰¦   «          w xY w)Nz/Could not flush Sentry events during loop closeTr1   )Úrun_until_completer9   r   Údebug)r<   ÚloopÚ
orig_closes   €€€r    Ú_patched_closez(patch_loop_close.<locals>._patched_closeS   s‰   ø€ ð	Ø×#Ò# F F¡H¤HÑ-Ô-Ð-Ð-øÝð 	ð 	ð 	ÝŒLØAÈDðñ ô ð ð ð ð	øøøð
 ˆJ‰LŒLˆLˆLˆLøˆJˆJ‰LŒLˆLˆLøøøs&   ƒ!  A ¡ AÁA ÁAÁA ÁAT©r   N)ÚasyncioÚget_running_loopÚRuntimeErrorr   Úcloser/   )rB   r<   r@   rA   s    @@@r    Úpatch_loop_closerH   6   s¸   øøø€ ð
ÝÔ'Ñ)Ô)ˆˆøÝð ð ð àˆˆðøøøõ ˆtÐ,¨eÑ4Ô4ð ØˆðVð Vð Vð Vð ”€Jðð ð ð ð ð ð ð ð  €D„JØ!%€DÔÐÐs   … ™
'¦'Úorig_task_factoryr@   úasyncio.AbstractEventLoopÚkwargsúasyncio.Task[Any]c                 ób   — d }| r
 | ||fi |¤Ž}|€t          |fd|i|¤Ž}|j        r|j        d= |S )Nr@   éÿÿÿÿ)r   Ú_source_traceback)rI   r@   r   rK   Útasks        r    Ú_create_task_with_factoryrQ   a   si   € ð €Dð ð 7Ø Ð   tÐ6Ð6¨vÐ6Ð6ˆà€|õ �DÐ.Ð.˜tÐ. vÐ.Ð.ˆØÔ!ð 	+ØÔ& rÐ*à€Kr"   c                  ó   ‡— d Š	 t          j        ¦   «         } |                      ¦   «         Št          ‰dd¦  «        rd S 	 	 	 	 	 	 	 	 dˆfd„}d|_        |                      |¦  «         d S # t          $ r t          j        d¦  «         Y d S w xY w)NÚ_is_sentry_task_factoryFr@   rJ   r   r$   rK   r   r   úasyncio.Future[Any]c                 ó  •‡— t          ¦   «         rt          ‰| ‰fi |¤ŽS t          ‰¦  «        dˆfd„¦   «         }t          ‰|  |¦   «         fi |¤Ž}	 |                     t	          ‰¦  «        › d�¦  «         n# t
          $ r Y nw xY w|S )Nr   r   c               “   ó  •K  — d } t          j        ¦   «         }|                     t          ¦  «        }|r|j        nd}d }t          |j        ¦  «        }t          j        ¦   «         5  |rž|rdt           j         	                    ¦   «         �Et           j         
                    t          ‰¦  «        t          j        t          j        dœ¬¦  «        }n8t          j
        t          j        t          ‰¦  «        t          j        ¬¦  «        }|r|nt          ¦   «         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 )NF)z	sentry.opzsentry.origin)ÚnameÚ
attributes)ÚoprW   Úorigin)r3   r4   Úget_integrationÚAsyncioIntegrationÚ
task_spansr   ÚoptionsÚisolation_scopeÚtracesÚget_current_spanÚ
start_spanr!   r   ÚFUNCTIONrZ   r   ÚStopAsyncIterationr9   r   Ú_capture_exception)Úresultr;   Úintegrationr]   Úspan_ctxÚis_span_streaming_enabledÚer   s          €r    Ú_task_with_sentry_span_creationzTpatch_asyncio.<locals>._sentry_task_factory.<locals>._task_with_sentry_span_creation‘   s"  øè è € à�Ý#Ô.Ñ0Ô0�Ø$×4Ò4Õ5GÑHÔH�Ø7BÐM˜[Ô3Ð3È�
àBF�Ý,FÀvÄ~Ñ,VÔ,VÐ)åÔ/Ñ1Ô1ð ;ð ;Ø!ð Ø4ð Ý)Ô0×AÒAÑCÔCÐOÝ+5Ô+<×+GÒ+GÝ)1°$©¬å57´[Ý9KÔ9Rð0&ð 0&ð ,Hñ ,"ô ," øõ (2Ô'<Ý#%¤;Ý%-¨d¡^¤^Ý'9Ô'@ð(ñ (ô (˜Hð &.Ð@˜˜µ;±=´=ð ;ð ;ð;Ø+/ Z Z Z Z Z Z˜F˜FøÝ1ð .ð .ð .Ø"#¨Ð-øøøøÝ(ð ;ð ;ð ;Ý#Õ%7Ñ%9Ô%9Ð:Ð:Ð:Ð:ð;øøøð;ð ;ð ;ñ ;ô ;ð ;ð ;ð ;ð ;ð ;ð ;øøøð ;ð ;ð ;ð ;ð%;ð ;ð ;ñ ;ô ;ð ;ð ;ð ;ð ;ð ;ð ;øøøð ;ð ;ð ;ð ;ð4 �sg   Á'B3E=ÄE&ÄD%Ä$E&Ä%
EÄ/D2Ä2"EÅE&ÅEÅE&ÅE=Å&E*	Å*E=Å-E*	Å.E=Å=FÆFz (Sentry-wrapped))r   r   )r   rQ   r-   Úset_namer!   ÚAttributeError)r@   r   rK   rk   rP   rI   s    `   €r    Ú_sentry_task_factoryz+patch_asyncio.<locals>._sentry_task_factory†   sí   øø€ õ  Ñ!Ô!ð Ý0Ø% t¨Tðð Ø5;ðð ð õ ˜TÑ"Ô"ð#ð #ð #ð #ð #ñ #Ô"ð#õJ -Ø! 4Ð)HÐ)HÑ)JÔ)Jðð ØNTðð ˆDð
Ø—’¥¨$¡¤ÐBÐBÐBÑCÔCÐCÐCøÝ!ð ð ð à�ðøøøð ˆKs   Á%A9 Á9
BÂBTzöThere 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@   rJ   r   r$   rK   r   r   rT   )	rD   rE   Úget_task_factoryr   rS   Úset_task_factoryrF   r   r:   )r@   rn   rI   s     @r    Úpatch_asynciorq   |   sù   ø€ ØÐðP
ÝÔ'Ñ)Ô)ˆØ ×1Ò1Ñ3Ô3Ðõ Ð$Ð&?ÀÑGÔGð 	ØˆFð<	Ø-ð<	à,ð<	ð ð<	ð #ð	<	ð <	ð <	ð <	ð <	ð <	ð| 8<ÐÔ4Ø×ÒÐ2Ñ3Ô3Ð3Ð3Ð3øåð 
ð 
ð 
åŒðPñ	
ô 	
ð 	
ð 	
ð 	
ð 	
ð
øøøs   …8A+ ¿*A+ Á+BÂBr   c                  óð   — t          j        ¦   «         } t          j        ¦   «         }|                     t
          ¦  «        }|�3t          | |j        dddœ¬¦  «        \  }}t          j        ||¬¦  «         | S )NrD   F)ÚtypeÚhandled)Úclient_optionsÚ	mechanism)Úhint)	Úsysr2   r3   r4   r[   r\   r
   r^   Úcapture_event)r2   r;   rg   Úeventrw   s        r    re   re   Ñ   s}   € ÝŒ|‰~Œ~€HåÔ"Ñ$Ô$€Fà×(Ò(Õ);Ñ<Ô<€KØÐÝ*ØØ!œ>Ø(°UÐ;Ð;ð
ñ 
ô 
‰ˆˆtõ
 	Ô  ¨TÐ2Ñ2Ô2Ð2à€Or"   c                   óF   — e Zd ZdZde› �Zd	deddfd„Zed
d„¦   «         ZdS )r\   rD   zauto.function.Tr]   r   Nc                 ó   — || _         d S ©N)r]   )Úselfr]   s     r    Ú__init__zAsyncioIntegration.__init__æ   s   € Ø$ˆŒˆˆr"   c                  ó>   — t          ¦   «          t          ¦   «          d S r}   )rq   rH   r'   r"   r    Ú
setup_oncezAsyncioIntegration.setup_onceé   s   € å‰ŒˆÝÑÔÐÐÐr"   )TrC   )	r   Ú
__module__r   Ú
identifierrZ   Úboolr   Ústaticmethodr�   r'   r"   r    r\   r\   â   sm   € € € € € Ø€JØ*˜jÐ*Ð*€Fð%ð % 4ð %°4ð %ð %ð %ð %ð ðð ð ñ „\ðð ð r"   r\   Úargsc                  óê   — t          j        ¦   «         }|                     ¦   «         sdS t          j        d¦  «         t          | i |¤Ž}|                     ¦   «          d|j        vr||j        d<   dS dS )a‹  
    Enable AsyncioIntegration with the provided options.

    This is useful in scenarios where Sentry needs to be initialized before
    an event loop is set up, but you still want to instrument asyncio once there
    is an event loop. In that case, you can sentry_sdk.init() early on without
    the AsyncioIntegration and then, once the event loop has been set up,
    execute:

    ```python
    from sentry_sdk.integrations.asyncio import enable_asyncio_integration

    async def async_entrypoint():
        enable_asyncio_integration()
    ```

    Any arguments provided will be passed to AsyncioIntegration() as is.

    If AsyncioIntegration has already patched the current event loop, this
    function won't have any effect.

    If AsyncioIntegration was provided in
    sentry_sdk.init(disabled_integrations=[...]), this function will ignore that
    and the integration will be enabled.
    NzSetting up integration asynciorD   )r3   r4   r5   r   r?   r\   r�   Úintegrations)r†   rK   r;   rg   s       r    Úenable_asyncio_integrationr‰   ï   s‹   € õ4 Ô"Ñ$Ô$€FØ×ÒÑÔð Øˆõ „LÐ1Ñ2Ô2Ð2å$ dÐ5¨fÐ5Ð5€KØ×ÒÑÔÐà˜Ô+Ð+Ð+Ø)4ˆÔ˜IÑ&Ð&Ð&ð ,Ð+r"   )r#   r$   r   r%   rC   )
rI   r   r@   rJ   r   r$   rK   r   r   rL   )r   r   )r†   r   rK   r   r   N)/r*   rx   r3   Úsentry_sdk.constsr   Úsentry_sdk.integrationsr   r   Úsentry_sdk.tracesr   Úsentry_sdk.tracingr   Úsentry_sdk.tracing_utilsr   Úsentry_sdk.transportr	   Úsentry_sdk.utilsr
   r   r   r   r   rD   Úasyncio.tasksr   ÚImportErrorÚtypingr   r   r   Úcollections.abcr   r   r   r   Úsentry_sdk._typesr   r   Ústrr!   r-   rH   rQ   rq   re   r\   r‰   r'   r"   r    ú<module>r—      s¶  ðØ Ð Ð Ð Ø 
€
€
€
à Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ø *Ð *Ð *Ð *Ð *Ð *Ø #Ð #Ð #Ð #Ð #Ð #Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3ðð ð ð ð ð ð ð ð ð ð ð ð ð ð0Ø€N€N€NØ"Ð"Ð"Ð"Ð"Ð"Ð"øØð 0ð 0ð 0Ø
ˆ,Ð.Ñ
/Ô
/Ð/ð0øøøð 2Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1àð /Ø)Ð)Ð)Ð)Ð)Ð)Ø-Ð-Ð-Ð-Ð-Ð-Ð-Ð-Ð-Ð-à)Ð)Ð)Ð)Ð)Ð)àˆ�˜8 C¨ HÔ-Ð.Ñ.Ô.€Að�5ð ˜Sð ð ð ð ðð ð ð ð(&ð (&ð (&ð (&ðVØðà
%ðð %ðð ð	ð
 ðð ð ð ð6R
ð R
ð R
ð R
ðjð ð ð ð"
ð 
ð 
ð 
ð 
˜ñ 
ô 
ð 
ð*5ð *5ð *5ð *5ð *5ð *5s   Á
A ÁA