.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, int|None suspended_time, str suspend_reason)
 resume (self)

Public Attributes

threading.Lock lock = threading.Lock()
int continuous_errors = 0
float suspend_end_time = 0
str suspend_reason = ""

Detailed Description

Class to handle suspend state.

Definition at line 77 of file abstract.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 80 of file abstract.py.

80 def __init__(self):
81 self.lock: threading.Lock = threading.Lock()
82 self.continuous_errors: int = 0
83 self.suspend_end_time: float = 0
84 self.suspend_reason: str = ""
85

Member Function Documentation

◆ is_suspended()

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

Definition at line 87 of file abstract.py.

87 def is_suspended(self):
88 return self.suspend_end_time >= default_timer()
89

References suspend_end_time.

◆ resume()

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

Definition at line 103 of file abstract.py.

103 def resume(self):
104 with self.lock:
105 # reset the suspend variables
106 self.continuous_errors = 0
107 self.suspend_end_time = 0
108 self.suspend_reason = ""
109
110

References continuous_errors, searx.metrics.models.CounterStorage.lock, lock, suspend_end_time, and suspend_reason.

◆ suspend()

searx.search.processors.abstract.SuspendedStatus.suspend ( self,
int | None suspended_time,
str suspend_reason )

Definition at line 90 of file abstract.py.

90 def suspend(self, suspended_time: int | None, suspend_reason: str):
91 with self.lock:
92 # update continuous_errors / suspend_end_time
93 self.continuous_errors += 1
94 if suspended_time is None:
95 max_ban: int = get_setting("search.max_ban_time_on_fail")
96 ban_fail: int = get_setting("search.ban_time_on_fail")
97 suspended_time = min(max_ban, ban_fail)
98
99 self.suspend_end_time = default_timer() + suspended_time
100 self.suspend_reason = suspend_reason
101 logger.debug("Suspend for %i seconds", suspended_time)
102

References continuous_errors, searx.get_setting(), searx.metrics.models.CounterStorage.lock, lock, suspend_end_time, and suspend_reason.

Here is the call graph for this function:

Member Data Documentation

◆ continuous_errors

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

Definition at line 82 of file abstract.py.

Referenced by resume(), and suspend().

◆ lock

threading.Lock searx.search.processors.abstract.SuspendedStatus.lock = threading.Lock()

Definition at line 81 of file abstract.py.

Referenced by resume(), and suspend().

◆ suspend_end_time

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

Definition at line 83 of file abstract.py.

Referenced by is_suspended(), resume(), and suspend().

◆ suspend_reason

str searx.search.processors.abstract.SuspendedStatus.suspend_reason = ""

Definition at line 84 of file abstract.py.

Referenced by resume(), and suspend().


The documentation for this class was generated from the following file:
  • /home/andrew/Documents/code/public/searxng/searx/search/processors/abstract.py