on master help sign in
[mod] searx.shared: minor tweaks
a0c8b41Alexandre Flament
searx/shared/shared_abstract.py+7−1
@@ -1,15 +1,21 @@
1# SPDX-License-Identifier: AGPL-3.0-or-later
1# SPDX-License-Identifier: AGPL-3.0-or-later
2+from abc import ABC, abstractmethod
2
3
3−class SharedDict:
4
4
5+class SharedDict(ABC):
6+
7+ @abstractmethod
5 def get_int(self, key):
8 def get_int(self, key):
6 pass
9 pass
7
10
11+ @abstractmethod
8 def set_int(self, key, value):
12 def set_int(self, key, value):
9 pass
13 pass
10
14
15+ @abstractmethod
11 def get_str(self, key):
16 def get_str(self, key):
12 pass
17 pass
13
18
19+ @abstractmethod
14 def set_str(self, key, value):
20 def set_str(self, key, value):
15 pass
21 pass
searx/shared/shared_uwsgi.py+3−2
@@ -44,14 +44,15 @@ def schedule(delay, func, *args):
44
44
45 def sighandler(signum):
45 def sighandler(signum):
46 now = int(time.time())
46 now = int(time.time())
47+ key = 'scheduler_call_time_signal_' + str(signum)
47 uwsgi.lock()
48 uwsgi.lock()
48 try:
49 try:
49− updating = uwsgi.cache_get('updating')
50+ updating = uwsgi.cache_get(key)
50 if updating is not None:
51 if updating is not None:
51 updating = int.from_bytes(updating, 'big')
52 updating = int.from_bytes(updating, 'big')
52 if now - updating < delay:
53 if now - updating < delay:
53 return
54 return
54− uwsgi.cache_update('updating', now.to_bytes(4, 'big'))
55+ uwsgi.cache_update(key, now.to_bytes(4, 'big'))
55 finally:
56 finally:
56 uwsgi.unlock()
57 uwsgi.unlock()
57 func(*args)
58 func(*args)