Ensure zkhandler is always cleaned up

Even if the subfunction of an API @ZKConnection call fails, the
zkhandler needs to terminate and clean up, or it leaves stuck threads
around.
This commit is contained in:
Joshua Boniface 2024-01-30 09:48:17 -05:00
parent df40b779af
commit 8419659e1b
1 changed files with 5 additions and 4 deletions

View File

@ -57,10 +57,11 @@ class ZKConnection(object):
schema_version = 0 schema_version = 0
zkhandler.schema.load(schema_version, quiet=True) zkhandler.schema.load(schema_version, quiet=True)
ret = function(zkhandler, *args, **kwargs) try:
ret = function(zkhandler, *args, **kwargs)
zkhandler.disconnect() finally:
del zkhandler zkhandler.disconnect()
del zkhandler
return ret return ret