Commit 4718a1c0 by tarokkk

fixing decorator to work as connection handler

parent 21d399b7
......@@ -10,12 +10,14 @@ connection = None
def req_connection(original_function):
'''Connection checking decorator for libvirt.
'''
def new_function(*args, **kwargs):
global connection
if connection is None:
connection = connect()
else:
connect()
try:
return_value = original_function(*args, **kwargs)
finally:
disconnect()
return return_value
return new_function
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment