Commit 4718a1c0 by tarokkk

fixing decorator to work as connection handler

parent 21d399b7
...@@ -10,14 +10,16 @@ connection = None ...@@ -10,14 +10,16 @@ connection = None
def req_connection(original_function): def req_connection(original_function):
'''Connection checking decorator for libvirt. '''Connection checking decorator for libvirt.
''' '''
def new_function(*args, **kwargs): def new_function(*args, **kwargs):
global connection global connection
if connection is None: if connection is None:
connection = connect() connect()
else: try:
return_value = original_function(*args, **kwargs) return_value = original_function(*args, **kwargs)
finally:
disconnect() disconnect()
return return_value return return_value
return new_function 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