Nir Soffer has uploaded a new change for review.
Change subject: procwatch: Rename CommandStream to ProcessWatcher
......................................................................
procwatch: Rename CommandStream to ProcessWatcher
This class is about watching child process standard streams, and
invoking callbacks when data is read from one of the streams.
Change-Id: I13981d80786bda2f185851febfd40754a38282a8
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/procwatch.py
M lib/vdsm/qemuimg.py
M tests/procwatch_test.py
3 files changed, 18 insertions(+), 18 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/73/65073/1
diff --git a/lib/vdsm/procwatch.py b/lib/vdsm/procwatch.py
index 1ae168a..fd4b543 100644
--- a/lib/vdsm/procwatch.py
+++ b/lib/vdsm/procwatch.py
@@ -27,7 +27,7 @@
from vdsm import utils
-class CommandStream(object):
+class ProcessWatcher(object):
def __init__(self, command, stdoutcb, stderrcb):
self._command = command
diff --git a/lib/vdsm/qemuimg.py b/lib/vdsm/qemuimg.py
index 8d60e4c..0527a15 100644
--- a/lib/vdsm/qemuimg.py
+++ b/lib/vdsm/qemuimg.py
@@ -203,7 +203,7 @@
with_ioclass=utils.IOCLASS.IDLE)
_log.debug(cmdutils.command_log_line(cmd, cwd=cwd))
self._command = CPopen(cmd, cwd=cwd, deathSignal=signal.SIGKILL)
- self._stream = procwatch.CommandStream(
+ self._watcher = procwatch.ProcessWatcher(
self._command, self._recvstdout, self._recvstderr)
def _recvstderr(self, buffer):
@@ -247,9 +247,9 @@
return self._command.poll() is not None
def poll(self, timeout=None):
- self._stream.receive(timeout=timeout)
+ self._watcher.receive(timeout=timeout)
- if not self._stream.closed:
+ if not self._watcher.closed:
return
self._command.wait()
diff --git a/tests/procwatch_test.py b/tests/procwatch_test.py
index e6b9d7f..8ed9d9f 100644
--- a/tests/procwatch_test.py
+++ b/tests/procwatch_test.py
@@ -30,7 +30,7 @@
@expandPermutations
-class CommandStreamTests(VdsmTestCase):
+class ProcessWatcherTests(VdsmTestCase):
def assertUnexpectedCall(self, data):
raise AssertionError("Unexpected data: %r" % data)
@@ -54,13 +54,13 @@
cmd[-1] = cmd[-1] % text
c = self._startCommand(cmd)
- p = procwatch.CommandStream(
+ watcher = procwatch.ProcessWatcher(
c,
recv_data if recv_out else self.assertUnexpectedCall,
recv_data if recv_err else self.assertUnexpectedCall)
- while not p.closed:
- p.receive()
+ while not watcher.closed:
+ watcher.receive()
retcode = c.wait()
@@ -81,7 +81,7 @@
operator.iadd(received, buffer)
c = self._startCommand(cmd)
- p = procwatch.CommandStream(
+ watcher = procwatch.ProcessWatcher(
c,
recv_data if recv_out else self.assertUnexpectedCall,
recv_data if recv_err else self.assertUnexpectedCall)
@@ -90,8 +90,8 @@
c.stdin.flush()
c.stdin.close()
- while not p.closed:
- p.receive()
+ while not watcher.closed:
+ watcher.receive()
retcode = c.wait()
@@ -100,13 +100,13 @@
def test_timeout(self):
c = self._startCommand(["sleep", "5"])
- p = procwatch.CommandStream(c, self.assertUnexpectedCall,
- self.assertUnexpectedCall)
+ watcher = procwatch.ProcessWatcher(c, self.assertUnexpectedCall,
+ self.assertUnexpectedCall)
with self.assertElapsed(2):
- p.receive(2)
+ watcher.receive(2)
- self.assertEqual(p.closed, False)
+ self.assertEqual(watcher.closed, False)
c.terminate()
@@ -118,14 +118,14 @@
))
def test_signals(self, method, expected_retcode):
c = self._startCommand(["sleep", "2"])
- p = procwatch.CommandStream(c, self.assertUnexpectedCall,
- self.assertUnexpectedCall)
+ watcher = procwatch.ProcessWatcher(c, self.assertUnexpectedCall,
+ self.assertUnexpectedCall)
getattr(c, method)()
try:
with self.assertElapsed(0):
- p.receive(2)
+ watcher.receive(2)
finally:
retcode = c.wait()
--
To view, visit
https://gerrit.ovirt.org/65073
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I13981d80786bda2f185851febfd40754a38282a8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>