관리-도구
편집 파일: sessions.cpython-311.pyc
� ^�Dg� � � � d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlmZ d dl m Z d dlmZ e r(d dl Z d dlmZ d dlmZ d d lmZ d d lmZ d dlmZ d dl mZ dd �Zedd�� � Zd� ZdZ G d� de� � Z G d� de� � ZdS )� N)�datetime)�Thread�Lock)�contextmanager)�MYPY)�format_timestamp)�Optional)�Union)�Any)�Dict)� Generator)� SessionStatusc � � | �t j j } | j j }|�0| j r| j j d ni }|� d� � }|S )z<Utility function to find out if session tracking is enabled.N�_experiments�auto_session_tracking)� sentry_sdk�Hub�current�scope�_force_auto_session_tracking�client�options�get)�hub�should_track�exps �J/opt/imunify360/venv/lib64/python3.11/site-packages/sentry_sdk/sessions.py� is_auto_session_tracking_enabledr sV � � �{��n�$���9�9�L���47�J�F�c�j� ��0�0�B���w�w�6�7�7���� c # �� K � | �t j j } t | � � }|r| � � � dV � |r| � � � dS dS # |r| � � � w w xY w)z8Starts and stops a session automatically around a block.N)r r r r � start_session�end_session)r r s r r r # s� � � � � �{��n�$��3�C�8�8�L�� �������� ����� ��O�O������ � ��<� ��O�O����� ���s �A �A3c �b � t | t j � � r| S t j | � � S �N)� isinstance�uuid�UUID)�vals r � _make_uuidr) 3 s+ � � �#�t�y�!�!� �� ��9�S�>�>�r )�exited�abnormal�crashedc �6 � e Zd Z d d�Zd� Zd� Zd� Zd� Zd� ZdS ) �SessionFlusher� c � � || _ || _ i | _ d | _ t � � | _ d | _ d| _ d S )NT)� flush_func�flush_interval�pending�_threadr �_thread_lock�_thread_for_pid�_running)�selfr1 r2 s r �__init__zSessionFlusher.__init__@ s@ � � %���,��������� �F�F���#����� � � r c � � | j }i | _ | � t |� � � � � � � d S r$ )r3 r1 �list�values)r8 r3 s r �flushzSessionFlusher.flushN s: � ��,���������W�^�^�-�-�.�.�/�/�/�/�/r c � � � � j t j � � k r � j �d S � j 5 � j t j � � k r� j � d d d � � d S � fd�}t |�� � }d|_ |� � � |� _ t j � � � _ d d d � � n# 1 swxY w Y d S )Nc � �� � j rDt j � j � � � j r� j r� � � � � j �Bd S d S r$ )r7 �time�sleepr2 r3 r= �r8 s �r r4 z/SessionFlusher._ensure_running.<locals>._thread\ s` �� ��m� %��J�t�2�3�3�3��|� %�� � %�� � ���� �m� %� %� %� %� %r )�targetT)r6 �os�getpidr4 r5 r �daemon�start)r8 r4 �threads ` r �_ensure_runningzSessionFlusher._ensure_runningT s" �� ���2�9�;�;�.�.�4�<�3K��4� � � /� /��#�r�y�{�{�2�2�t�|�7O�� /� /� /� /� /� /� /� /� %� %� %� %� %� �7�+�+�+�F� �F�M��L�L�N�N�N�!�D�L�#%�9�;�;�D� � /� /� /� /� /� /� /� /� /� /� /���� /� /� /� /� �ts �%B;� AB;�;B?�B?c �z � |� � � | j |j j <