관리-도구
편집 파일: threaded.cpython-311.pyc
� �܋f� � �� � d Z ddlmZ ddlZddlZddlZddlZddlmZmZ ddl m Z ddlmZ ddl mZmZ dZ ej d � � Z G d � de� � Z G 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 �^ � e Zd Z e� � Zefd�Zd� Zd� Zd� Z d� Z d� Zdd�Zd � Z d � ZdS )�AsyncWorkerc �� � t � � t d� � | _ t j � � | _ d | _ d | _ d|i| _ | � � � d S )N����shutdown_timeout) r r �_queue� threading�Lock�_lock�_thread�_thread_for_pid�options�start)�selfr s �O/opt/cloudlinux/venv/lib64/python3.11/site-packages/raven/transport/threaded.py�__init__zAsyncWorker.__init__ sX � ������B�i�i����^�%�%�� ����#���� 0� ��� � � ������ c �~ � | j t j � � k rdS | j o| j � � � S )NF)r �os�getpidr �is_alive�r s r r zAsyncWorker.is_alive( s6 � ���2�9�;�;�.�.��5��|�7��� 5� 5� 7� 7�7r c �Z � | � � � rd S | � � � d S �N)r r r s r �_ensure_threadzAsyncWorker._ensure_thread- s( � ��=�=�?�?� ��F�� � �����r c �B � | j 5 | � � � s d d d � � d S | j � | j � � | j d }t d|� � }| � |� � s�| j � � � }t d|z � � t d|z � � t j dk rt d� � nt d� � | � ||z � � d | _ d d d � � d S # 1 swxY w Y d S )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 r r � put_nowait�_terminatorr �min�_timed_queue_join�qsize�printr �namer )r �timeout�initial_timeout�sizes r �main_thread_terminatedz"AsyncWorker.main_thread_terminated2 s� � � �Z� � ��=�=�?�?� �� � � � � � � � � �K�"�"�4�#3�4�4�4��l�#5�6�G� "�#�w�/�/�O��)�)�/�:�:� B� �{�(�(�*�*���N��� � � ��0�7�:�;�;�;��7�d�?�?��4�5�5�5�5��0�1�1�1��&�&�w��'@�A�A�A��D�L�= � � � � � � � � � � � ���� � � � � � s �D�CD�D�Dc � � t � � |z }| j }|j � � � |j rU|t � � z }|dk r |j � � � dS |j � |�� � |j �U |j � � � dS # |j � � � w xY w)z� implementation of Queue.join which takes a 'timeout' argument returns true on success, false on timeout r F�r- T)r r �all_tasks_done�acquire�unfinished_tasks�release�wait)r r- �deadline�queue�delays r r) zAsyncWorker._timed_queue_joinS s� � � �6�6�G�#����� ��$�$�&�&�&� +��(� 9� �4�6�6�)���A�:�:� � � �(�(�*�*�*�*�*� �$�)�)�%�)�8�8�8� �(� 9� � � �(�(�*�*�*�*�*��E� �(�(�*�*�*�*���s �B+ �-"B+ �+Cc � � | j � � � | � � � skt j | j d�� � | _ | j � d� � | j � � � t j � � | _ | j � � � t j | j � � dS # | j � � � t j | j � � w xY w)z) Starts the task thread. zraven.AsyncWorker)�targetr, TN)r r4 r r �Thread�_targetr � setDaemonr r r r r6 �atexit�registerr0 r s r r zAsyncWorker.startk s� � � � ������ 9��=�=�?�?� 3�(�/�t�|�J]�^�^�^�����&�&�t�,�,�,���"�"�$�$�$�')�y�{�{��$��J��� � � ��O�D�7�8�8�8�8�8�� �J��� � � ��O�D�7�8�8�8�8���s �A?C �4DNc �� � | j 5 | j rH| j � | j � � | j � |�� � d| _ d| _ ddd� � dS # 1 swxY w Y dS )z5 Stops the task thread. Synchronous! r2 N)r r r r&