관리-도구
편집 파일: __init__.cpython-37.pyc
B ��Y2 � @ st d Z ddlmZ ddlmZ ddlmZ ddlmZm Z ddl m Z ddlm Z G dd � d e �ZG d d� de�ZdS ) z� raven.contrib.tornado ~~~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2012 by the Sentry Team, see AUTHORS for more details :license: BSD, see LICENSE for more details � )�absolute_import)�partial)�ioloop)�AsyncHTTPClient� HTTPError)r )�Clientc sN e Zd ZdZ� fdd�Zdd� Zddd�Zdd d �Zdd� Zdd d�Z � Z S )�AsyncSentryClientz� A mixin class that could be used along with request handlers to asynchronously send errors to sentry. The client also captures the information from the request handlers c s$ |� dd�| _tt| �j||� d S )N� validate_certT)�popr �superr �__init__)�self�args�kwargs)� __class__� �O/opt/alt/python37/lib/python3.7/site-packages/raven/contrib/tornado/__init__.pyr s zAsyncSentryClient.__init__c O s@ | � � sdS | j||�}| jf d|�dd�i|��}|d |fS )a Takes the same arguments as the super function in :py:class:`Client` and extracts the keyword argument callback which will be called on asynchronous sending of the request :return: a 32-length string identifying this event N�callbackZevent_id)� is_enabledZ build_msg�send�get)r r r �data�futurer r r �capture s zAsyncSentryClient.captureNc K s | � |�}| j|||d�S )zV Serializes the message and passes the payload onto ``send_encoded``. )�auth_headerr )�encodeZsend_encoded)r r r r �messager r r r / s zAsyncSentryClient.sendc C s` |d kri }| j �� s.| �|�}| �|� d S | j||||d�}tj�� �|t | j ||�� |S )N)�urlr �headersr )�stateZ should_try�decodeZ_log_failed_submission�_send_remoter ZIOLoop�currentZ add_futurer �_handle_result)r r r r r r r r r �send_remote7 s zAsyncSentryClient.send_remotec C s� y|� � W nr tk rF } z| �|�}| �|||� W d d }~X Y nD tk r~ } z| �|�}| �|||� W d d }~X Y nX | j�� d S )N)�resultr r Z_failed_send� Exceptionr Zset_success)r r r r �er r r r# F s z AsyncSentryClient._handle_resultc C s&