File: //lib/python3.6/site-packages/fail2ban/server/__pycache__/jailthread.cpython-36.pyc
3
UB(d� � @ s� d Z dZdZddlZddlmZ ddlmZ ddlm Z d d
l
mZmZ G dd� de�Z
ejdk rle
je
_nee
d�s~e
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�Ze dd� �Zdd� Z
e 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 sJ t t��j|d� d�_d �_d�_tj�_�j � � �fdd�}|�_ d S )N)�nameTFc s\ y� | |� �j � W n@ tk
rV } z$td k r>ttj� � nt|� W Y d d }~X nX d S )N)�onStop� Exception�sysr �exc_info�print)�args�kwargs�e)�run�self� � /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 )r r
r )� __class__)r r r r 4 s zJailThread.__init__� c s t | j� tt| �j� S )N)r r
r r �
_bootstrap)r )r r r r R s
zJailThread._bootstrapc C s t | j� tj| �S )N)r r
r �_Thread__bootstrap)r r r r Z__bootstrapV s
zJailThread.__bootstrap�basicc C s dS )z0Abstract - Should provide status information.
Nr )r Zflavorr r r �statusZ 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! ` s zJailThread.startc C s dS )z2Abstract - Called when thread ends (after run).
Nr )r r r r r f s zJailThread.onStopc C s
d| _ dS )zASets `active` property to False, to flag run method to return.
FN)r )r r r r �stopl s zJailThread.stopc C s dS )zCAbstract - Called when thread starts, thread stops when returns.
Nr )r r r r r q 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# w s
zJailThread.join)N)r )r )�__name__�
__module__�__qualname__�__doc__r r
�version_infor �_JailThread__bootstrapr r r! r r"