AlkantarClanX12

Your IP : 3.149.250.19


Current Path : /opt/alt/python37/lib/python3.7/site-packages/raven/transport/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/raven/transport/__pycache__/threaded.cpython-37.pyc

B

��Yu�@s�dZddlmZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddl
mZmZdZe�d	�ZGd
d�de�ZGdd
�d
e
e�ZdS)z�
raven.transport.threaded
~~~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
�)�absolute_importN)�sleep�time)�AsyncTransport)�
HTTPTransport)�Queue�
check_threads�
z
sentry.errorsc@s`eZdZe�Zefdd�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zddd�Zdd�Z
dd�Zd
S)�AsyncWorkercCs<t�td�|_t��|_d|_d|_d|i|_|�	�dS)N����shutdown_timeout)
rr�_queue�	threading�Lock�_lock�_thread�_thread_for_pid�options�start)�selfr�r�I/opt/alt/python37/lib/python3.7/site-packages/raven/transport/threaded.py�__init__s


zAsyncWorker.__init__cCs"|jt��krdS|jo |j��S)NF)r�os�getpidr�is_alive)rrrrr(szAsyncWorker.is_alivecCs|��rdS|��dS)N)rr)rrrr�_ensure_thread-szAsyncWorker._ensure_threadcCs�|j��z�|��sdS|j�|j�|jd}td|�}|�|�s�|j�	�}t
d|�t
d|�tjdkrzt
d�nt
d�|�||�d|_
Wd|j��XdS)Nrg�������?z6Sentry is attempting to send %i pending error messageszWaiting up to %s seconds�ntzPress Ctrl-Break to quitzPress Ctrl-C to quit)r�acquirerr
�
put_nowait�_terminatorr�min�_timed_queue_join�qsize�printr�namer�release)r�timeoutZinitial_timeout�sizerrr�main_thread_terminated2s$







z"AsyncWorker.main_thread_terminatedcCs`t�|}|j}|j��z4x.|jrJ|t�}|dkr:dS|jj|d�qWdS|j��XdS)z�
        implementation of Queue.join which takes a 'timeout' argument

        returns true on success, false on timeout
        rF)r'TN)rr
�all_tasks_doner�unfinished_tasks�waitr&)rr'Zdeadline�queue�delayrrrr"Ws


zAsyncWorker._timed_queue_joinc	Csf|j��z>|��sFtj|jdd�|_|j�d�|j��t	�
�|_Wd|j��t
�|j�XdS)z)
        Starts the task thread.
        zraven.AsyncWorker)�targetr%TN)rrrr�Thread�_targetr�	setDaemonrrrrr&�atexit�registerr))rrrrros


zAsyncWorker.startNcCsN|j��z2|jr:|j�|j�|jj|d�d|_d|_Wd|j��XdS)z5
        Stops the task thread. Synchronous!
        )r'N)	rrrr
rr �joinrr&)rr'rrr�stop~s

zAsyncWorker.stopcOs|��|j�|||f�dS)N)rr
r)r�callback�args�kwargsrrrr-�szAsyncWorker.queuecCsvxp|j��}zL||jkrP|\}}}y|||�Wn"tk
rTtjddd�YnXWd|j��Xtd�qWdS)NzFailed processing jobT)�exc_infor)r
�getr �	Exception�logger�error�	task_doner)r�recordr7r8r9rrrr1�s


zAsyncWorker._target)N)�__name__�
__module__�__qualname__�objectr �DEFAULT_TIMEOUTrrrr)r"rr6r-r1rrrrr
s%
r
cs8eZdZddddgZdd�Z�fdd�Zd	d
�Z�ZS)�ThreadedHTTPTransport�http�httpsz
threaded+httpzthreaded+httpscCs"t|d�r|j��st�|_|jS)N�_worker)�hasattrrIrr
)rrrr�
get_worker�sz ThreadedHTTPTransport.get_workerc
sNytt|��|||�Wn*tk
rB}z||�Wdd}~XYnX|�dS)N)�superrF�sendr<)r�url�data�headers�
success_cb�
failure_cb�e)�	__class__rr�	send_sync�s
zThreadedHTTPTransport.send_synccCs|���|j|||||�dS)N)rKr-rU)rrNrOrPrQrRrrr�
async_send�sz ThreadedHTTPTransport.async_send)rArBrC�schemerKrUrV�
__classcell__rr)rTrrF�srF)�__doc__�
__future__rr3�loggingrrrrZraven.transport.baserZraven.transport.httprZraven.utils.compatrrrE�	getLoggerr=rDr
rFrrrr�<module>s