changeset 7897:0666876afad7

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.
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 03 Oct 2019 23:04:58 +0200
parents 8dbe46ca608f
children 9d74cc23ea64
files kallithea/bin/ldap_sync.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/bin/ldap_sync.py	Thu Oct 03 22:52:53 2019 +0200
+++ b/kallithea/bin/ldap_sync.py	Thu Oct 03 23:04:58 2019 +0200
@@ -153,7 +153,7 @@
         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 @@
                 # TODO: handle somehow maybe..
                 pass
 
+    def close(self):
+        self.ldap_client.close()
+
 
 if __name__ == '__main__':
     sync = LdapSync()
@@ -253,3 +256,5 @@
         # 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()