File: //lib/python3.6/site-packages/fail2ban/server/__pycache__/jailthread.cpython-36.pyc
3
=�Z]� � @ sX d Z dZdZddlZddlmZ ddlmZ ddlm Z d d
l
mZ G dd� de�ZdS )
z
Cyril Jaquierz Copyright (c) 2004 Cyril JaquierZGPL� N)�Thread)�abstractmethod� )�Utils� )�
excepthookc s\ e Zd ZdZd� fdd� Zeddd��Z� fdd �Zd
d� Zedd
� �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 y� | |� W n@ t k
rN } z$td k r6ttj� � nt|� W Y d d }~X nX d S )N)� Exception�sysr �exc_info�print)�args�kwargs�e)�run� � /usr/lib/python3.6/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__�basicc C s dS )z0Abstract - Should provide status information.
Nr )r Zflavorr r r �statusO s zJailThread.statusc s d| _ tt| �j� dS )z&Sets active flag and starts thread.
TN)r r r �start)r )r r r r U s zJailThread.startc C s
d| _ dS )zASets `active` property to False, to flag run method to return.
FN)r )r r r r �stop[ s zJailThread.stopc C s dS )zCAbstract - Called when thread starts, thread stops when returns.
Nr )r r r r r ` s zJailThread.runc s | j dk rtt| �j� dS )z` Safer join, that could be called also for not started (or ended) threads (used for cleanup).
N)r r r �join)r )r r r r f s
zJailThread.join)N)r )�__name__�
__module__�__qualname__�__doc__r r r r r r r �
__classcell__r r )r r r # s r )
�
__author__Z
__copyright__Z__license__r Z threadingr �abcr Zutilsr Zhelpersr r r r r r �<module> s