.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 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 = ""

Static Private Attributes

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

Detailed Description

Class to handle suspend state.

Definition at line 27 of file abstract.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 32 of file abstract.py.

32 def __init__(self):
33 self.lock: threading.Lock = threading.Lock()
34 self.continuous_errors: int = 0
35 self.suspend_end_time: float = 0
36 self.suspend_reason: str = ""
37

Member Function Documentation

◆ is_suspended()

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

Definition at line 39 of file abstract.py.

39 def is_suspended(self):
40 return self.suspend_end_time >= default_timer()
41

References suspend_end_time.

◆ resume()

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

Definition at line 55 of file abstract.py.

55 def resume(self):
56 with self.lock:
57 # reset the suspend variables
58 self.continuous_errors = 0
59 self.suspend_end_time = 0
60 self.suspend_reason = ""
61
62

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

◆ suspend()

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

Definition at line 42 of file abstract.py.

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

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

Member Data Documentation

◆ __slots__

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

Definition at line 30 of file abstract.py.

◆ continuous_errors

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

Definition at line 34 of file abstract.py.

Referenced by resume(), and suspend().

◆ lock

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

Definition at line 33 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 35 of file abstract.py.

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

◆ suspend_reason

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

Definition at line 36 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