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:
parent
df40b779af
commit
8419659e1b
|
@ -57,10 +57,11 @@ class ZKConnection(object):
|
|||
schema_version = 0
|
||||
zkhandler.schema.load(schema_version, quiet=True)
|
||||
|
||||
ret = function(zkhandler, *args, **kwargs)
|
||||
|
||||
zkhandler.disconnect()
|
||||
del zkhandler
|
||||
try:
|
||||
ret = function(zkhandler, *args, **kwargs)
|
||||
finally:
|
||||
zkhandler.disconnect()
|
||||
del zkhandler
|
||||
|
||||
return ret
|
||||
|
||||
|
|
Loading…
Reference in New Issue