summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-01-11 18:44:39 +0100
committerAlexandre Flament <alex@al-f.net>2021-01-12 11:47:17 +0100
commita0c8b413a610e8cde49dbb321ba17b16200eb92f (patch)
treeff82e0504670b6486dc5c70826554467ea957fda /searx
parent87bafbc32b34ef7f3033bdea6a4bfa966a6068c1 (diff)
downloadsearxng-a0c8b413a610e8cde49dbb321ba17b16200eb92f.tar.gz
searxng-a0c8b413a610e8cde49dbb321ba17b16200eb92f.zip
[mod] searx.shared: minor tweaks
searx.shared.shared_abstract.SharedDict inherit from abc.ABC searx.shared.shared_uwsgi.schedule can schedule multiple functions without issue
Diffstat (limited to 'searx')
-rw-r--r--searx/shared/shared_abstract.py8
-rw-r--r--searx/shared/shared_uwsgi.py5
2 files changed, 10 insertions, 3 deletions
diff --git a/searx/shared/shared_abstract.py b/searx/shared/shared_abstract.py
index 3fede417e..b1c72aabe 100644
--- a/searx/shared/shared_abstract.py
+++ b/searx/shared/shared_abstract.py
@@ -1,15 +1,21 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+from abc import ABC, abstractmethod
-class SharedDict:
+class SharedDict(ABC):
+
+ @abstractmethod
def get_int(self, key):
pass
+ @abstractmethod
def set_int(self, key, value):
pass
+ @abstractmethod
def get_str(self, key):
pass
+ @abstractmethod
def set_str(self, key, value):
pass
diff --git a/searx/shared/shared_uwsgi.py b/searx/shared/shared_uwsgi.py
index 136bf687e..b42b5fa7b 100644
--- a/searx/shared/shared_uwsgi.py
+++ b/searx/shared/shared_uwsgi.py
@@ -44,14 +44,15 @@ def schedule(delay, func, *args):
def sighandler(signum):
now = int(time.time())
+ key = 'scheduler_call_time_signal_' + str(signum)
uwsgi.lock()
try:
- updating = uwsgi.cache_get('updating')
+ updating = uwsgi.cache_get(key)
if updating is not None:
updating = int.from_bytes(updating, 'big')
if now - updating < delay:
return
- uwsgi.cache_update('updating', now.to_bytes(4, 'big'))
+ uwsgi.cache_update(key, now.to_bytes(4, 'big'))
finally:
uwsgi.unlock()
func(*args)