Change in vdsm[master]: hooks: use the `terminating' decorator
fromani at redhat.com
fromani at redhat.com
Mon Jan 18 12:50:33 UTC 2016
Francesco Romani has uploaded a new change for review.
Change subject: hooks: use the `terminating' decorator
......................................................................
hooks: use the `terminating' decorator
Make use of the new `terminating' decorator
utility yo make sure we don't leak processes.
Change-Id: Ica692d8b330b71e1fed6fb9df1546ce3a37ade7d
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm_hooks/checkimages/before_vm_start.py
1 file changed, 18 insertions(+), 14 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/52349/1
diff --git a/vdsm_hooks/checkimages/before_vm_start.py b/vdsm_hooks/checkimages/before_vm_start.py
index 40a1326..e7b212a 100755
--- a/vdsm_hooks/checkimages/before_vm_start.py
+++ b/vdsm_hooks/checkimages/before_vm_start.py
@@ -7,6 +7,9 @@
import struct
import hooking
+from vdsm.utils import terminating
+
+
BLKGETSIZE64 = 0x80081272 # Obtain device size in bytes
FORMAT = 'L'
TIMEPERGIB = 0.02 # Approximate qemu-img check time (in seconds) to check 1GiB
@@ -77,22 +80,23 @@
# on timeout expiration
p = hooking.execCmd(cmd, raw=True, sync=False)
- if not p.wait(timeout):
- p.kill()
- sys.stderr.write('checkimages: %s image check operation timed out.' %
- path)
- sys.stderr.write('Increate timeout or check image availability.')
- sys.exit(2)
+ with terminating(p):
+ if p.wait(timeout) is None:
+ p.kill()
+ sys.stderr.write('checkimages: %s image check operation timed out.' %
+ path)
+ sys.stderr.write('Increate timeout or check image availability.')
+ sys.exit(2)
- ((out, err), rc) = (p.communicate(), p.returncode)
+ ((out, err), rc) = (p.communicate(), p.returncode)
- if rc == 0:
- sys.stderr.write('checkimages: %s image check returned: %s\n' %
- (path, out))
- else:
- sys.stderr.write('checkimages: Error running %s command: %s\n' %
- (' '.join(cmd), err))
- sys.exit(2)
+ if rc == 0:
+ sys.stderr.write('checkimages: %s image check returned: %s\n' %
+ (path, out))
+ else:
+ sys.stderr.write('checkimages: Error running %s command: %s\n' %
+ (' '.join(cmd), err))
+ sys.exit(2)
if 'checkimages' in os.environ:
--
To view, visit https://gerrit.ovirt.org/52349
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica692d8b330b71e1fed6fb9df1546ce3a37ade7d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
More information about the vdsm-patches
mailing list