| Current Path : /usr/lib/python3/dist-packages/fail2ban/server/__pycache__/ |
| Current File : //usr/lib/python3/dist-packages/fail2ban/server/__pycache__/jailthread.cpython-38.pyc |
U
ܜ^u � @ sn d Z dZdZddlZddlmZ ddlmZ ddlm Z d d
l
mZmZ G dd� de�Z
ejd
k rje
je
_dS )z
Cyril Jaquierz Copyright (c) 2004 Cyril JaquierZGPL� N)�Thread)�abstractmethod� )�Utils� )�
excepthook�prctl_set_th_namec s| e Zd ZdZd� fdd� Zejdkr2� fdd�Zndd � Ze ddd��Z
� fd
d�Zdd� Ze dd� �Z
� fdd�Z� ZS )�
JailThreada Abstract class for threading elements in Fail2Ban.
Attributes
----------
daemon
ident
name
status
active : bool
Control the state of the thread.
idle : bool
Control the idle state of the thread.
sleeptime : int
The time the thread sleeps for in the loop.
Nc sH t t| �j|d� d| _d | _d| _tj| _| j � � fdd�}|| _ d S )N)�nameTFc
sT z� | |� W n@ t k
rN } z"td k r6tt�� � nt|� W 5 d }~X Y nX d S �N)� Exception�sysr �exc_info�print)�args�kwargs�e��run� �</usr/lib/python3/dist-packages/fail2ban/server/jailthread.py�run_with_except_hookC s z1JailThread.__init__.<locals>.run_with_except_hook)
�superr �__init__Zdaemon�activeZidler ZDEFAULT_SLEEP_TIMEZ sleeptimer )�selfr
r �� __class__r r r 4 s
zJailThread.__init__�� c s t | j� tt| ��� S r )r r
r r �
_bootstrap�r r r r r P s
zJailThread._bootstrapc C s t | j� t�| �S r )r r
r �_Thread__bootstrapr! r r r Z__bootstrapT s
zJailThread.__bootstrap�basicc C s dS )z0Abstract - Should provide status information.
Nr )r Zflavorr r r �statusX s zJailThread.statusc s d| _ tt| ��� dS )z&Sets active flag and starts thread.
TN)r r r �startr! r r r r% ^ s zJailThread.startc C s
d| _ dS )zASets `active` property to False, to flag run method to return.
FN)r r! r r r �stopd s zJailThread.stopc C s dS )zCAbstract - Called when thread starts, thread stops when returns.
Nr r! r r r r i s zJailThread.runc s | j dk rtt| ��� dS )z` Safer join, that could be called also for not started (or ended) threads (used for cleanup).
N)r r r �joinr! r r r r'