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@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()
gerrit-hooks has posted comments on this change.
Change subject: procwatch: Rename CommandStream to ProcessWatcher ......................................................................
Patch Set 1:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
gerrit-hooks has posted comments on this change.
Change subject: procwatch: Rename CommandStream to ProcessWatcher ......................................................................
Patch Set 2:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
gerrit-hooks has posted comments on this change.
Change subject: procwatch: Rename CommandStream to ProcessWatcher ......................................................................
Patch Set 3:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
gerrit-hooks has posted comments on this change.
Change subject: procwatch: Rename CommandStream to ProcessWatcher ......................................................................
Patch Set 4:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
gerrit-hooks has posted comments on this change.
Change subject: procwatch: Rename CommandStream to ProcessWatcher ......................................................................
Patch Set 5:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
gerrit-hooks has posted comments on this change.
Change subject: procwatch: Rename CommandStream to ProcessWatcher ......................................................................
Patch Set 6:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Freddy Rolland has posted comments on this change.
Change subject: procwatch: Rename CommandStream to ProcessWatcher ......................................................................
Patch Set 6: Code-Review+1
vdsm-patches@lists.fedorahosted.org