ok

Mini Shell

Direktori : /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�	threadingZLock�_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_joinZqsize�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
Zall_tasks_donerZunfinished_tasks�waitr$)rr%Zdeadline�queueZdelayrrrr!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)rrrrZThread�_targetrZ	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�errorZ	task_doner)r�recordr0r1r2rrrr+�s


zAsyncWorker._target)N)�__name__�
__module__�__qualname__�objectr�DEFAULT_TIMEOUTrrrr'r!rr/r)r+rrrrr
s%
r
cs8eZdZddddgZdd�Z�fdd�Zd	d
�Z�ZS)�ThreadedHTTPTransportZhttpZhttpsz
threaded+httpzthreaded+httpscCs"t|d�r|j��st�|_|jS)N�_worker)�hasattrr?rr
)rrrr�
get_worker�sz ThreadedHTTPTransport.get_workerc
sNytt|��|||�Wn*tk
rB}z||�Wdd}~XYnX|�dS)N)�superr>�sendr5)r�url�data�headers�
success_cb�
failure_cb�e)�	__class__rr�	send_sync�s
zThreadedHTTPTransport.send_synccCs|���|j|||||�dS)N)rAr)rK)rrDrErFrGrHrrr�
async_send�sz ThreadedHTTPTransport.async_send)r9r:r;ZschemerArKrL�
__classcell__rr)rJrr>�sr>)�__doc__Z
__future__rr,ZloggingrrrrZraven.transport.baserZraven.transport.httprZraven.utils.compatrrr=Z	getLoggerr6r<r
r>rrrr�<module>s


Zerion Mini Shell 1.0