관리-도구
편집 파일: daemon.cpython-39.pyc
a ,�g4 � @ s� d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dl m Z d dlmZ d dlm Z d dlmZ d dlZej�� ZG dd� de�ZdS ) � N)�TunedException)�InvalidProfileException)�commands)�exports)�ProfileRecommenderc @ s e Zd Zd;dd�Zdd� Zdd� Zdd � Zd d� Zdd � Zdd� Z d<dd�Z edd� �Zedd� �Z edd� �Zedd� �Zedd� �Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd)d*� Zd+d,� Zd-d.� Zd/d0� Zd1d2� Zd3d4� Zd5d6� Zd7d8� Zd=d9d:�ZdS )>�DaemonNc C s� t �d� tj| _ttj�| _ttj�| _ tj | _d| _tj | _|d ur�|�tjtj�| _t|�tjtj��| _t|�tjtj��| _ |�tjtj �| _|�tjtj�| _|�tjtj �| _|| _| jdkr�ttj�| _| j dkr�d| _n| j | jk r�| j| _ | j | j | _t �d| j � | j�rJt �d� t �d| j| j | jf � t| j d�| _|| _|| _| �� t � | _!z| �"|� W n4 t#�y� } zt �$d | � W Y d }~n d }~0 0 d S ) Nzinitializing daemonTr Fz$using sleep interval of %d second(s)z8dynamic tuning is enabled (can be overridden by plugins)zFusing update interval of %d second(s) (%d times of the sleep interval))Zis_hardcodedz:Cannot set initial profile. No tunings will be enabled: %s)%�log�debug�constsZCFG_DEF_DAEMON�_daemon�intZCFG_DEF_SLEEP_INTERVAL�_sleep_intervalZCFG_DEF_UPDATE_INTERVALZ_update_intervalZCFG_DEF_DYNAMIC_TUNING�_dynamic_tuningZ_recommend_commandZCFG_DEF_ROLLBACK� _rollbackZget_boolZ CFG_DAEMON�getZCFG_SLEEP_INTERVALZCFG_UPDATE_INTERVALZCFG_DYNAMIC_TUNINGZCFG_RECOMMEND_COMMANDZCFG_DEF_RECOMMEND_COMMAND�CFG_ROLLBACK�_application� _sleep_cycles�infor �_profile_recommender� _unit_manager�_profile_loader� _init_threadsr �_cmd� _init_profiler �error)�selfZunit_manager�profile_loader� profile_namesZconfigZapplication�e� r �7/usr/lib/python3.9/site-packages/tuned/daemon/daemon.py�__init__ sF zDaemon.__init__c C sP d | _ t�� | _t�� | _t�� | _t�� | _t�� | _| j�� t�� | _ d S �N) �_thread� threading�Event� _terminate�_terminate_profile_switch� _not_used�_sighup_processingZ_sighup_pending�set�_profile_applied�r r r r! r 7 s zDaemon._init_threadsc C s | � d� dS )zARead configuration files again and load profile according to themN)r r- r r r! �reload_profile_configE s zDaemon.reload_profile_configc C s� d}| j �� }|d u rP| �� \}}|d u rrd}|r<|d7 }n|d7 }t�|� n"|dkrr|rht�d� n t�d� d | _d | _g | _d | _| � |||� d S )NTz.No profile is preset, running in manual mode. z(Only post-loaded profile will be enabledzNo profile will be enabled.� ) r Zget_post_loaded_profile�_get_startup_profiler r �_profile�_manual�_active_profiles�_post_loaded_profile�set_all_profiles)r r �manual�post_loaded_profile�msgr r r! r I s&