# HG changeset patch # User Mads Kiilerich # Date 2019-10-03 23:04:58 # Node ID 0666876afad7979b8f293cd2be9f0967efbf0b5e # Parent 8dbe46ca608f9af67f0b1b83cc2218e9970f1ba0 bin: let ldap_sync use explicit .close() instead of relying on unbinding in .__del__() It is unknown how important timely unbinding really is. Especially in this short-lived (unused?) standalone program. But let's avoid any doubt. diff --git a/kallithea/bin/ldap_sync.py b/kallithea/bin/ldap_sync.py --- a/kallithea/bin/ldap_sync.py +++ b/kallithea/bin/ldap_sync.py @@ -153,7 +153,7 @@ class LdapClient(object): self.client.simple_bind(user, key) self.base_dn = base_dn - def __del__(self): + def close(self): self.client.unbind() def get_groups(self): @@ -241,6 +241,9 @@ class LdapSync(object): # TODO: handle somehow maybe.. pass + def close(self): + self.ldap_client.close() + if __name__ == '__main__': sync = LdapSync() @@ -253,3 +256,5 @@ if __name__ == '__main__': # we need to find a way to recognize the right exception (we always get # ResponseError with no error code so maybe by return msg (?) sync.update_memberships_from_ldap(gr) + + sync.close()