diff options
author | Alexandre Flament <alex@al-f.net> | 2022-07-15 18:38:32 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2022-11-05 12:04:50 +0100 |
commit | fe419e355bf1527c51e3aee98495d08b89510320 (patch) | |
tree | 0ed03d5e3d77e68ac5a5834e5890f5f27fe29fe7 /searx/shared/redisdb.py | |
parent | d764d94a70b0b10291105a867227975d59af5675 (diff) | |
download | searxng-fe419e355bf1527c51e3aee98495d08b89510320.tar.gz searxng-fe419e355bf1527c51e3aee98495d08b89510320.zip |
The checker requires Redis
Remove the abstraction in searx.shared.SharedDict.
Implement a basic and dedicated scheduler for the checker using a Redis script.
Diffstat (limited to 'searx/shared/redisdb.py')
-rw-r--r-- | searx/shared/redisdb.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/searx/shared/redisdb.py b/searx/shared/redisdb.py index bb7a0eeb4..d0071f72c 100644 --- a/searx/shared/redisdb.py +++ b/searx/shared/redisdb.py @@ -26,26 +26,20 @@ import redis from searx import get_setting -logger = logging.getLogger('searx.shared.redis') +logger = logging.getLogger('searx.shared.redisdb') _client = None -def client(): - global _client # pylint: disable=global-statement - if _client is None: - # not thread safe: in the worst case scenario, two or more clients are - # initialized only one is kept, the others are garbage collected. - _client = redis.Redis.from_url(get_setting('redis.url')) +def client() -> redis.Redis: return _client -def init(): +def initialize(): + global _client # pylint: disable=global-statement try: - c = client() - logger.info("connected redis DB --> %s", c.acl_whoami()) - return True + _client = redis.Redis.from_url(get_setting('redis.url')) + logger.info("connected redis: %s", get_setting('redis.url')) except redis.exceptions.ConnectionError as exc: _pw = pwd.getpwuid(os.getuid()) logger.error("[%s (%s)] can't connect redis DB ...", _pw.pw_name, _pw.pw_uid) logger.error(" %s", exc) - return False |