관리-도구
편집 파일: processor.cpython-37.pyc
B � dy � @ s� d Z ddlZddlZddlZddlZddlmZmZ ddlmZm Z m Z ddlmZm Z ddlmZ ddlmZ dd lmZ dd lmZ ddlmZmZmZmZ dd lmZ ddlmZmZm Z eG dd� de��Z!dS )z- This module contains RequestProcessor class � N)�datetime� timedelta)�Thread�RLock�current_thread)�Callable�Any� )� AutoTracer)�Common)� DecisionMaker)�StatisticsSender� )� session_scope�setup_database� RequestResult�cleanup_old_data)�SSAError)� singleton� url_split�switch_schedstatsc s� e Zd ZdZdZd#� fdd� Zedd� �Zed�d d �Z dd�dd �Z dd�dd�Zee d�dd�Zd$ed�dd�Zdd� Zeeed�dd��Zdd� Zd%dd�Zedd �d!d"�Z� ZS )&�RequestProcessorz^ SSA Request processor implementation. Only one instance is allowed to be created �d Nc sx t � �� t�d�| _| j�dt� tdd� |r6|nt� | _ t � | _t|d�| _ t� | _t|d�| _| �� g | _d S )NZ req_processorzProcessor enabled: %sT)�enabled)�engine)�super�__init__�logging� getLogger�logger�info�__package__r r r r �_lockr �decision_makerr �senderr �auto_tracer�start_background_routine�_buffer)�selfr )� __class__� �F/opt/alt/python37/lib/python3.7/site-packages/ssa/modules/processor.pyr ) s zRequestProcessor.__init__c C s | j d S )zp Return config file value multiplied by 1000000, as we receive duration in microseconds i@B )Zrequests_duration)r( r* r* r+ �configured_duration= s z$RequestProcessor.configured_duration)�reportc C sJ y| j �|� W n4 tk rD } z| j�dt|�� W dd}~X Y nX dS )z( Call Statistics Sender zStatisticsSender failed: %sN)r$ �sendr r �error�str)r( r- �er* r* r+ � send_statsE s zRequestProcessor.send_stats)�returnc C s* t | jdd�}|�� | j�d|j� dS )zA Start dumper|DecisionMaker thread in background T)�target�daemonz[%s] Routine startedN)r �background_routine�startr r �name)r( �tr* r* r+ r&