GkcdZdZdZddlZddlmZddlmZddlm Z d d l m Z m Z Gd d eZ ejd kre je _yee dse j$e _yy)z Cyril Jaquierz Copyright (c) 2004 Cyril JaquierGPLN)Thread)abstractmethod)Utils) excepthookprctl_set_th_nameceZdZdZd fd Zej dk\rfdZndZe d dZ fdZ e dZ d Z e d Zfd ZxZS) JailThreadaAbstract 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. ctt |d_d_d_t j_jfd}|_ y)N)nameTFc |i|jy#t$r;}tttjnt |Yd}~yYd}~yd}~wwxYwN)onStop Exceptionsysr exc_infoprint)argskwargserunselfs .run_with_except_hookCsQ KKM    1XX! s A ,AA ) superr __init__daemonactiveidlerDEFAULT_SLEEP_TIME sleeptimer)rrrr __class__s` @rrzJailThread.__init__4sP D""-$+$+$)++$. # "$(cRt|jtt|Sr)r rrr _bootstraprr$s rr)zJailThread._bootstrapRsTYY  D , ..r%cVt|jtj|Sr)r rr_Thread__bootstraprs r __bootstrapzJailThread.__bootstrapVsTYY  # #D ))r%cy)z0Abstract - Should provide status information. N)rflavors rstatuszJailThread.statusZr%c8d|_tt|y)z&Sets active flag and starts thread. TN)r rr startr*s rr5zJailThread.start`s$+ D!r%cy)z2Abstract - Called when thread ends (after run). Nr0r-s rrzJailThread.onStopfr3r%cd|_y)zASets `active` property to False, to flag run method to return. FN)r r-s rstopzJailThread.stopls $+r%cy)zCAbstract - Called when thread starts, thread stops when returns. Nr0r-s rrzJailThread.runqr3r%cD|jtt|yy)z` Safer join, that could be called also for not started (or ended) threads (used for cleanup). N)r rr joinr*s rr;zJailThread.joinws!  [[T!r%r)basic)__name__ __module__ __qualname____doc__rr version_infor)_JailThread__bootstraprr2r5rr8rr; __classcell__)r$s@rr r #sw ":0* "    ""r%r r&isAlive) __author__ __copyright__ __license__r threadingrabcrutilsrhelpersr r r rArBr,hasattris_aliverDr0r%rrNso. 2  3["["|d!+!B!B Y '!*** (r%