관리-도구
편집 파일: sys_exit.cpython-38.pyc
U �Mg� � @ s| d dl Z d dlZd dlZd dlmZmZ d dlmZ d dlm Z e r`d dl mZ d dlm Z mZ G dd� de�Zd d � ZdS )� N)�capture_internal_exceptions�event_from_exception)�Integration)� TYPE_CHECKING)�Callable)�NoReturn�Unionc @ s: e Zd ZdZdZdd�dd�Zedd� �Zed d � �ZdS )�SysExitIntegrationaM Captures sys.exit calls and sends them as events to Sentry. By default, SystemExit exceptions are not captured by the SDK. Enabling this integration will capture SystemExit exceptions generated by sys.exit calls and send them to Sentry. This integration, in its default configuration, only captures the sys.exit call if the exit code is a non-zero and non-None value (unsuccessful exits). Pass `capture_successful_exits=True` to capture successful exits as well. Note that the integration does not capture SystemExit exceptions raised outside a call to sys.exit. Zsys_exitF)�capture_successful_exitsc C s || _ d S �N)�_capture_successful_exits)�selfr � r �N/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/sys_exit.py�__init__ s zSysExitIntegration.__init__c C s t �� d S r )r �_patch_sys_exitr r r r � setup_once s zSysExitIntegration.setup_oncec s( t j� t�� �d� fdd� �} | t _d S )Nr c s~ t �� �t�}|d kr� | � z� | � W nN tk rx } z0t� � |jsR| dkrZt|� W 5 Q R X |�W 5 d }~X Y nX d S )N)r N)� sentry_sdk� get_clientZget_integrationr � SystemExitr r �_capture_exception)Z_SysExitIntegration__statusZintegration�e�Zold_exitr r �sentry_patched_exit) s z?SysExitIntegration._patch_sys_exit.<locals>.sentry_patched_exit)r )�sys�exit� functools�wraps)r r r r r $ s z"SysExitIntegration._patch_sys_exitN) �__name__� __module__�__qualname__�__doc__� identifierr �staticmethodr r r r r r r s r c C s2 t | t�� jtjdd�d�\}}tj||d� d S )NF)�typeZhandled)Zclient_optionsZ mechanism)�hint)r r r �optionsr r"