diff --git a/searx/search/checker/background.py b/searx/search/checker/background.py index be30897b..e41bff5f 100644 --- a/searx/search/checker/background.py +++ b/searx/search/checker/background.py @@ -40,8 +40,9 @@ def get_result(): return json.loads(serialized_result) -def _set_result(result): - result['timestamp'] = int(time.time() / 3600) * 3600 +def _set_result(result, include_timestamp=True): + if include_timestamp: + result['timestamp'] = int(time.time() / 3600) * 3600 storage.set_str(CHECKER_RESULT, json.dumps(result)) @@ -82,8 +83,8 @@ def _run_with_delay(): def _start_scheduling(): every = _get_every() - schedule(every[0], _run_with_delay) - run() + if schedule(every[0], _run_with_delay): + run() def _signal_handler(signum, frame): @@ -111,7 +112,7 @@ def initialize(): return # - _set_result({'status': 'unknown'}) + _set_result({'status': 'unknown'}, include_timestamp=False) start_after = scheduling.get('start_after', (300, 1800)) start_after = _get_interval(start_after, 'checker.scheduling.start_after is not a int or list') diff --git a/searx/shared/__init__.py b/searx/shared/__init__.py index 83d3a274..cbe24d23 100644 --- a/searx/shared/__init__.py +++ b/searx/shared/__init__.py @@ -22,7 +22,7 @@ else: from .shared_simple import SimpleSharedDict as SharedDict def schedule(delay, func, *args): - pass + return False else: # uwsgi from .shared_uwsgi import UwsgiCacheSharedDict as SharedDict, schedule diff --git a/searx/shared/shared_simple.py b/searx/shared/shared_simple.py index 5b970aad..48d8cb82 100644 --- a/searx/shared/shared_simple.py +++ b/searx/shared/shared_simple.py @@ -36,3 +36,4 @@ def schedule(delay, func, *args): func(*args) call_later() + return True diff --git a/searx/shared/shared_uwsgi.py b/searx/shared/shared_uwsgi.py index b42b5fa7..a6dba9f5 100644 --- a/searx/shared/shared_uwsgi.py +++ b/searx/shared/shared_uwsgi.py @@ -61,3 +61,4 @@ def schedule(delay, func, *args): _last_signal += 1 uwsgi.register_signal(signal_num, 'worker', sighandler) uwsgi.add_timer(signal_num, delay) + return True