Change in vdsm[master]: link monitor: replace events() with optionally continuous it...

nsoffer at redhat.com nsoffer at redhat.com
Thu Dec 12 15:22:49 UTC 2013


Nir Soffer has posted comments on this change.

Change subject: link monitor: replace events() with optionally continuous iteration
......................................................................


Patch Set 12:

(1 comment)

....................................................
File lib/vdsm/ipwrapper.py
Line 589:             for line in self.proc.stdout:
Line 590:                 yield self._parseLine(line)
Line 591:         else:
Line 592:             for event in self._events():
Line 593:                 yield event
One thing worry me here - what if I run the monitor forever, and it dies.

Your iterator is using the first code path (self.proc.returncode == None). On the next iteration, self.proc.returncode becomes a number, and you invoke self._events() - does it work correctly?

It would be nice to see a test simulating this, like:

    # Get some events while monitor is running:

    # Monitor write line 1
    e = mon.next()
     
    # Monitor write line 2
    e = mon.next()
    
    # Monitor write line 3
    
    # Kill it
    mon.stop()
    e = mon.next()

    assertRaises(StopIteration, mon.next)

Maybe it is more correct to return 2 iterators, one for the first option, and one for the second.

    def __iter__(self):
        raise if not running
        if self.proc.returncode is None:
            return self._iterForever
        else:
            return iter(self._events)

    def self._iterForever(self):
        self.proc.blocking = True
        for line in self.proc.stdout:
            yield self._parseLine(line)
Line 594: 
Line 595:     def start(self):
Line 596:         self.proc = execCmd([_IP_BINARY.cmd, '-d', '-o', 'monitor', 'link'],
Line 597:                             sync=False)


-- 
To view, visit http://gerrit.ovirt.org/21430
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib8ca850fc324a5b4c0268541fd4d4d062706a159
Gerrit-PatchSet: 12
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Assaf Muller <amuller at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list