a =*fN@sndZdZdZddlZddlmZddlmZddlm Z d d l m Z m Z Gd d d eZ ee d sje je _dS)z Cyril Jaquierz Copyright (c) 2004 Cyril JaquierZGPLN)Thread)abstractmethod)Utils) excepthookprctl_set_th_namecsteZdZdZdfdd ZfddZeddd Zfd d Zed d Z ddZ eddZ fddZ Z S) 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. NcsJttj|dd_d_d_tj_j fdd}|_ dS)N)nameTFc sbz|i|WnBty\}z*tdur@ttnt|WYd}~n d}~00dSN)onStop Exceptionsysrexc_infoprint)argskwargserunself>/usr/lib/python3.9/site-packages/fail2ban/server/jailthread.pyrun_with_except_hookCs z1JailThread.__init__..run_with_except_hook) superr __init__daemonactiveZidlerZDEFAULT_SLEEP_TIMEZ sleeptimer)rr r __class__rrr4s zJailThread.__init__cst|jtt|Sr )rr rr _bootstraprrrrr Qs zJailThread._bootstrapbasiccCsdS)z0Abstract - Should provide status information. Nr)rZflavorrrrstatusUszJailThread.statuscsd|_tt|dS)z&Sets active flag and starts thread. TN)rrr startr!rrrr$[szJailThread.startcCsdS)z2Abstract - Called when thread ends (after run). Nrr!rrrr aszJailThread.onStopcCs d|_dS)zASets `active` property to False, to flag run method to return. FN)rr!rrrstopgszJailThread.stopcCsdS)zCAbstract - Called when thread starts, thread stops when returns. Nrr!rrrrlszJailThread.runcs|jdurtt|dS)z` Safer join, that could be called also for not started (or ended) threads (used for cleanup). N)rrr joinr!rrrr&rs zJailThread.join)N)r")__name__ __module__ __qualname____doc__rr rr#r$r r%rr& __classcell__rrrrr #s     r isAlive) __author__Z __copyright__Z __license__r threadingrabcrZutilsrZhelpersrrr hasattris_aliver,rrrrs   Y