관리-도구
편집 파일: monitor.cpython-38.pyc
U �Mg~ � @ sf d dl Z d dlZd dlmZmZ d dlZd dlmZ d dlm Z e rPd dlm Z dZG dd� d�ZdS ) � N)�Thread�Lock)�logger)� TYPE_CHECKING)�Optional� c @ sb e Zd ZdZdZddd�Zdd� Zdd � Zd d� Zdd � Z dd� Z edd� �Zdd� Z dd� ZdS )�Monitorz� Performs health checks in a separate thread once every interval seconds and updates the internal state. Other parts of the SDK only read this state and act accordingly. zsentry.monitorr c C s6 || _ || _d| _d| _d | _t� | _d | _d| _d S )NTr ) � transport�interval�_healthy�_downsample_factor�_threadr �_thread_lock�_thread_for_pid�_running)�selfr r � r �@/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/monitor.py�__init__ s zMonitor.__init__c s� � j t�� kr� jdk rdS � j�� � j t�� krJ� jdk rJW 5 Q R � dS � fdd�}t� j|d�}d|_z|�� W n& t k r� d� _ Y W 5 Q R � dS X |� _t�� � _ W 5 Q R X dS )a- Check that the monitor has an active thread to run in, or create one if not. Note that this might fail (e.g. in Python 3.12 it's not possible to spawn new threads at interpreter shutdown). In that case self._running will be False after running this function. Nc s&