From ade97bc90f88ae84cb1e46f5638e0525647194e8 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 27 May 2022 14:11:40 +0200 Subject: [PATCH] LdapClient: init cache in __init__ method and reset it during initialization Fix cache sharing problem when multiple clients are used on same soft --- mylib/ldap.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mylib/ldap.py b/mylib/ldap.py index 7874f78..6cd0a84 100644 --- a/mylib/ldap.py +++ b/mylib/ldap.py @@ -346,13 +346,14 @@ class LdapClient: _conn = None # Cache objects - _cached_objects = dict() + _cached_objects = None def __init__(self, options=None, options_prefix=None, config=None, config_section=None, initialize=False): self._options = options if options else {} self._options_prefix = options_prefix if options_prefix else 'ldap_' self._config = config if config else None self._config_section = config_section if config_section else 'ldap' + self._cached_objects = {} if initialize: self.initialize() @@ -404,6 +405,8 @@ class LdapClient: uri, dn=binddn, pwd=self._get_option('bindpwd'), raiseOnError=True ) + # Reset cache + self._cached_objects = {} return self._conn.connect() def decode(self, value):