.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.search.processors.abstract.SuspendedStatus Class Reference

Public Member Functions

 __init__ (self)
 
 is_suspended (self)
 
 suspend (self, suspended_time, suspend_reason)
 
 resume (self)
 

Public Attributes

 lock = threading.Lock()
 
int continuous_errors = 0
 
int suspend_end_time = 0
 
 suspend_reason = None
 
int lock = 1
 

Static Private Attributes

str __slots__ = 'suspend_end_time', 'suspend_reason', 'continuous_errors', 'lock'
 

Detailed Description

Class to handle suspend state.

Definition at line 22 of file abstract.py.

Constructor & Destructor Documentation

◆ __init__()

searx.search.processors.abstract.SuspendedStatus.__init__ ( self)

Definition at line 27 of file abstract.py.

27 def __init__(self):
28 self.lock = threading.Lock()
29 self.continuous_errors = 0
30 self.suspend_end_time = 0
31 self.suspend_reason = None
32

Member Function Documentation

◆ is_suspended()

searx.search.processors.abstract.SuspendedStatus.is_suspended ( self)

Definition at line 34 of file abstract.py.

34 def is_suspended(self):
35 return self.suspend_end_time >= default_timer()
36

References searx.search.processors.abstract.SuspendedStatus.suspend_end_time.

◆ resume()

searx.search.processors.abstract.SuspendedStatus.resume ( self)

Definition at line 50 of file abstract.py.

50 def resume(self):
51 with self.lock:
52 # reset the suspend variables
53 self.continuous_errors = 0
54 self.suspend_end_time = 0
55 self.suspend_reason = None
56
57

References searx.search.processors.abstract.SuspendedStatus.continuous_errors, searx.metrics.models.CounterStorage.lock, searx.search.processors.abstract.SuspendedStatus.lock, searx.search.processors.abstract.SuspendedStatus.suspend_end_time, and searx.search.processors.abstract.SuspendedStatus.suspend_reason.

◆ suspend()

searx.search.processors.abstract.SuspendedStatus.suspend ( self,
suspended_time,
suspend_reason )

Definition at line 37 of file abstract.py.

37 def suspend(self, suspended_time, suspend_reason):
38 with self.lock:
39 # update continuous_errors / suspend_end_time
40 self.continuous_errors += 1
41 if suspended_time is None:
42 suspended_time = min(
43 settings['search']['max_ban_time_on_fail'],
44 self.continuous_errors * settings['search']['ban_time_on_fail'],
45 )
46 self.suspend_end_time = default_timer() + suspended_time
47 self.suspend_reason = suspend_reason
48 logger.debug('Suspend for %i seconds', suspended_time)
49

Member Data Documentation

◆ __slots__

str searx.search.processors.abstract.SuspendedStatus.__slots__ = 'suspend_end_time', 'suspend_reason', 'continuous_errors', 'lock'
staticprivate

Definition at line 25 of file abstract.py.

◆ continuous_errors

int searx.search.processors.abstract.SuspendedStatus.continuous_errors = 0

Definition at line 29 of file abstract.py.

Referenced by searx.search.processors.abstract.SuspendedStatus.resume().

◆ lock [1/2]

◆ lock [2/2]

◆ suspend_end_time

int searx.search.processors.abstract.SuspendedStatus.suspend_end_time = 0

◆ suspend_reason

searx.search.processors.abstract.SuspendedStatus.suspend_reason = None

Definition at line 31 of file abstract.py.

Referenced by searx.search.processors.abstract.SuspendedStatus.resume().


The documentation for this class was generated from the following file: