Skip to contentSkip to conversation

master - lvmdbusd: Only read whats buffered

PATCH tasleson 1 participant 1 message Nov 24, 2016

lore
Share & tools
lore

tasleson

author
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=064e24bc1e9f5b84a5987febaf0d11e5aeae39e2
Commit:        064e24bc1e9f5b84a5987febaf0d11e5aeae39e2
Parent:        a7404b5b830479e9ff7dd634e015c9ebcdb9b20b
Author:        Tony Asleson <[email protected]>
AuthorDate:    Wed Nov 23 14:49:23 2016 -0600
Committer:     Tony Asleson <[email protected]>
CommitterDate: Wed Nov 23 18:16:11 2016 -0600

lvmdbusd: Only read whats buffered

When reading data from stdout & stderr we were reading until the reading until we got None back which really isn't needed as the read will return everything that is available.

---
 daemons/lvmdbusd/lvm_shell_proxy.py |   19 ++++++-------------
 1 files changed, 6 insertions(+), 13 deletions(-)
daemons/lvmdbusd/lvm_shell_proxy.py +6 -13
index 8d15e10..50f2201 100755
@@ -64,13 +64,9 @@ class LVMShellProxy(object):
 
 				for r in ready[0]:
 					if r == self.lvm_shell.stdout.fileno():
-						while True:
-							tmp = self.lvm_shell.stdout.read()
-							if tmp:
-								stdout += tmp.decode("utf-8")
-							else:
-								break
-
+						tmp = self.lvm_shell.stdout.read()
+						if tmp:
+							stdout += tmp.decode("utf-8")
 					elif r == self.report_r:
 						while True:
 							tmp = os.read(self.report_r, 16384)
@@ -82,12 +78,9 @@ class LVMShellProxy(object):
 								break
 
 					elif r == self.lvm_shell.stderr.fileno():
-						while True:
-							tmp = self.lvm_shell.stderr.read()
-							if tmp:
-								stderr += tmp.decode("utf-8")
-							else:
-								break
+						tmp = self.lvm_shell.stderr.read()
+						if tmp:
+							stderr += tmp.decode("utf-8")
 
 				# Check to see if the lvm process died on us
 				if self.lvm_shell.poll():