mirror of
https://github.com/searxng/searxng
synced 2024-11-05 06:01:05 +00:00
[pylint] checker/__main__.py & checker/background.py
Lint files that has been touched by [PR #58] [PR #58] https://github.com/searxng/searxng/pull/58 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
8c1a65d32f
commit
fa0d05c313
@ -1,4 +1,6 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# lint: pylint
|
||||||
|
# pylint: disable=missing-module-docstring, missing-function-docstring
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import io
|
import io
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# lint: pylint
|
||||||
|
# pylint: disable=missing-module-docstring, missing-function-docstring
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
@ -34,7 +36,7 @@ def _get_every():
|
|||||||
return _get_interval(every, 'checker.scheduling.every is not a int or list')
|
return _get_interval(every, 'checker.scheduling.every is not a int or list')
|
||||||
|
|
||||||
|
|
||||||
def get_result():
|
def get_result(): # pylint: disable=inconsistent-return-statements
|
||||||
serialized_result = storage.get_str(CHECKER_RESULT)
|
serialized_result = storage.get_str(CHECKER_RESULT)
|
||||||
if serialized_result is not None:
|
if serialized_result is not None:
|
||||||
return json.loads(serialized_result)
|
return json.loads(serialized_result)
|
||||||
@ -47,7 +49,7 @@ def _set_result(result, include_timestamp=True):
|
|||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
if not running.acquire(blocking=False):
|
if not running.acquire(blocking=False): # pylint: disable=consider-using-with
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
logger.info('Starting checker')
|
logger.info('Starting checker')
|
||||||
@ -66,7 +68,7 @@ def run():
|
|||||||
|
|
||||||
_set_result(result)
|
_set_result(result)
|
||||||
logger.info('Check done')
|
logger.info('Check done')
|
||||||
except Exception:
|
except Exception: # pylint: disable=broad-except
|
||||||
_set_result({'status': 'error'})
|
_set_result({'status': 'error'})
|
||||||
logger.exception('Error while running the checker')
|
logger.exception('Error while running the checker')
|
||||||
finally:
|
finally:
|
||||||
@ -87,7 +89,7 @@ def _start_scheduling():
|
|||||||
run()
|
run()
|
||||||
|
|
||||||
|
|
||||||
def _signal_handler(signum, frame):
|
def _signal_handler(_signum, _frame):
|
||||||
t = threading.Thread(target=run)
|
t = threading.Thread(target=run)
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
t.start()
|
t.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user