Changeset - 0666876afad7
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2019-10-03 23:04:58
mads@kiilerich.com
Grafted from: 11549162718a
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.
1 file changed with 6 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/ldap_sync.py
Show inline comments
 
@@ -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()
0 comments (0 inline, 0 general)