o
    S۷i                     @   s   d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	 e	r0d dlm
Z
 d dlmZ deded	dfd
dZG dd deZdS )    N)logger)Integration)TYPE_CHECKING)Any)Optionalpendingtimeoutreturnc                 C   sR   dt ddfdd}|d|   |d|  |dtjd	krd
pd  tj  dS )zThis is the default shutdown callback that is set on the options.
    It prints out a message to stderr that informs the user that some events
    are still pending and the process is waiting for them to flush out.
    msgr	   Nc                 S   s   t j| d  d S )N
)sysstderrwrite)r
    r   T/home/ubuntu/vllm_env/lib/python3.10/site-packages/sentry_sdk/integrations/atexit.pyecho   s   zdefault_callback.<locals>.echoz.Sentry is attempting to send %i pending eventszWaiting up to %s secondszPress Ctrl-%s to quitntBreakC)strosnamer   r   flush)r   r   r   r   r   r   default_callback   s
   r   c                   @   s*   e Zd ZdZd
dddZeddd	ZdS )AtexitIntegrationatexitNcallbackOptional[Any]r	   c                 C   s   |d u rt }|| _d S N)r   r   )selfr   r   r   r   __init__!   s   
zAtexitIntegration.__init__c                  C   s   t jddd} d S )Nr	   c                  S   sP   t  } | t}|d u rd S td td t    | j|j	d d S )Nzatexit: got shutdown signalzatexit: shutting down client)r   )

sentry_sdk
get_clientget_integrationr   r   debugget_isolation_scopeend_sessioncloser   )clientintegrationr   r   r   	_shutdown(   s   


z/AtexitIntegration.setup_once.<locals>._shutdownr	   N)r   register)r*   r   r   r   
setup_once&   s   zAtexitIntegration.setup_oncer   )r   r   r	   Nr+   )__name__
__module____qualname__
identifierr    staticmethodr-   r   r   r   r   r      s
    r   )r   r   r   r!   sentry_sdk.utilsr   sentry_sdk.integrationsr   typingr   r   r   intr   r   r   r   r   r   <module>   s    