관리-도구
편집 파일: tools.cpython-37.pyc
B � d � @ s� d dl Z d dlZd dlZd dlmZmZmZ ddlmZm Z ddl mZ e �d�Z edd�d d �Zedd�dd�Zeedd �dd�Zdd� Zdefeeef edd�dd�ZdS )� N)�Union�Iterable�Callable� )�switch_schedstats�no_xray_active_tasks� )�RequestProcessor�tools)�signum�returnc C s t �d| | � dS )z/ Signal handler to log received signal zReceived sig: %i (%s)N)�logger�info)r �frame� r �C/opt/alt/python37/lib/python3.7/site-packages/ssa/internal/tools.py�log_on_receive s r c C sJ t �d| � t� �� t �d| � t� r<t �d� tdd� t�d� dS )zO Signal handler to dump collected statistics and switch off schedstats zReceived sig: %iz/Dumped successfully after %i signal, exiting...z0No X-Ray tasks running, switching schedstats offF)�enabledr N)r r r �flush_bufferr r �sys�exit)r r r r r �sigterm_received s r )r � sighandlerr c C sV yt � | |� t�d| � W n4 ttfk rP } zt�d| |� W dd}~X Y nX dS )z4 Register given sighandler for given signum z Registered %szSkipped %s because of %sN)�signalr r �OSError� ValueError)r r �er r r �register_a_signal) s r c C s t tjt� dS )z4 Register a dump handler for SIGTERM signal N)r r �SIGTERMr r r r r �register_sigterm4 s r )�signals�handlerr c C sV | dkr$xHt jD ]}t||� qW n.t| t�r:t| |� nx| D ]}t||� q@W dS )z� Register given handler for given signal or range of signals If no signals given, add given handler for all available signals N)r �Signalsr � isinstance�int)r r! �sigr r r �register_signals; s r&