Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/sentry_sdk/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/sentry_sdk/__pycache__/worker.cpython-35.pyc



��\�
�@s�ddlZddlmZmZddlmZmZddlmZmZddl	m
Z
e�ZGdd�de�Z
dS)�N)�Thread�Lock)�sleep�time)�queue�check_thread_support)�loggerc@s�eZdZdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
dd�Z
dd�Zdd�Zdd�Z
d
S)�BackgroundWorkercCs;t�tjd�|_t�|_d|_d|_dS)N����)rrZQueue�_queuer�_lock�_thread�_thread_for_pid)�self�r�B/opt/alt/python35/lib/python3.5/site-packages/sentry_sdk/worker.py�__init__s
	zBackgroundWorker.__init__cCs3|jtj�krdS|js&dS|jj�S)NF)r�os�getpidr�is_alive)rrrrrs
	zBackgroundWorker.is_alivecCs|js|j�dS)N)r�start)rrrr�_ensure_thread$s	zBackgroundWorker._ensure_threadc
Cs�t�|}|j}|jj�zHx=|jre|t�}|dkrOdS|jjd|�q)WdSWd|jj�XdS)NrF�timeoutT)rrZall_tasks_done�acquireZunfinished_tasks�wait�release)rrZdeadliner�delayrrr�_timed_queue_join)s
	

z"BackgroundWorker._timed_queue_joincCse|j�U|jsZtd|jdd�|_|jjd�|jj�tj�|_	WdQRXdS)N�target�namezraven-sentry.BackgroundWorkerT)
r
rr�_targetr�	setDaemonrrrr)rrrrr8s
	
zBackgroundWorker.startc	CsMtjd�|j�0|jrB|jjt�d|_d|_WdQRXdS)Nz"background worker got kill request)r�debugr
rr�
put_nowait�_TERMINATORr)rrrr�killCs

		zBackgroundWorker.killNc
CsTtjd�|j�*|jr<|dkr<|j||�WdQRXtjd�dS)Nz#background worker got flush requestgzbackground worker flushed)rr#r
r�_wait_flush)rr�callbackrrr�flushLs


zBackgroundWorker.flushcCsktd|�}|j|�sg|jj�}tjd|�|dk	rV|||�|j||�dS)Ng�������?z%d event(s) pending on flush)�minrrZqsizerr#)rrr(Zinitial_timeout�pendingrrrr'Ts
zBackgroundWorker._wait_flushcCs|j�|jj|�dS)N)rrr$)rr(rrr�submit^s
zBackgroundWorker.submitcCsyxr|jj�}zD|tkr"Py|�Wn%tk
rTtjddd�YnXWd|jj�Xtd�qWdS)NzFailed processing job�exc_infoTr)r�getr%�	Exceptionr�errorZ	task_doner)rr(rrrr!cs
zBackgroundWorker._target)�__name__�
__module__�__qualname__r�propertyrrrrr&r)r'r,r!rrrrr	s		
r	)r�	threadingrrrrZsentry_sdk._compatrrZsentry_sdk.utilsr�objectr%r	rrrr�<module>s