Change in vdsm[master]: link monitor: Add optional asynchronous operation

asegurap at redhat.com asegurap at redhat.com
Fri Dec 6 13:00:01 UTC 2013


Antoni Segura Puimedon has posted comments on this change.

Change subject: link monitor: Add optional asynchronous operation
......................................................................


Patch Set 6:

(7 comments)

....................................................
Commit Message
Line 3: AuthorDate: 2013-11-19 17:26:47 +0100
Line 4: Commit:     Antoni S. Puimedon <asegurap at redhat.com>
Line 5: CommitDate: 2013-12-04 17:53:17 +0100
Line 6: 
Line 7: link monitor: Add optional asynchronous operation
How about
link monitor: allow iterating on a non-stopped monitor.
Line 8: 
Line 9: Apart from the current way of operating a moniter:
Line 10:     mon = Monitor()
Line 11:     mon.start()


Line 10:     mon = Monitor()
Line 11:     mon.start()
Line 12:     ....
Line 13:     mon.stop()
Line 14:     eventList = mon.events()
You don't lose them. It's how we use it right now for the functional tests. Once you stop it, calling events() will give you the events that happened between start and stop.
Line 15: 
Line 16: Now it is possible to do (async iteration):
Line 17:     mon = Monitor()
Line 18:     mon.start()


Line 23:     mon = Monitor()
Line 24:     mon.start()
Line 25:     mon.stop()
Line 26:     for event in mon:
Line 27:         do things with the event
Please, clarify what is wrong in iterating through the events and using them to perform actions.
Line 28: 
Line 29: This is the first step towards having a thread that keeps netinfo
Line 30: updated by events.
Line 31: 


....................................................
File lib/vdsm/ipwrapper.py
Line 553:     Can be used in synchronous and asynchronous mode:
Line 554:         mon = Monitor()
Line 555:         mon.start()
Line 556:         ....
Line 557:         mon.stop()  # This makes it synced iteration.
s/must/can/

If you stop it. The iteration will be through all the events that happened between start and stop. If you don't stop it, you will be iterating through the events forever.
Line 558:         for event in mon:
Line 559:             print event
Line 560:     """
Line 561:     _DELETED_TEXT = 'Deleted'


Line 565:         self.proc = None
Line 566: 
Line 567:     def __iter__(self):
Line 568:         if self.proc is None:
Line 569:             raise StopIteration
Done
Line 570:         elif self.proc.returncode is None:
Line 571:             for line in self.proc.stdout:
Line 572:                 yield self._parseLine(line)
Line 573:         else:


Line 566: 
Line 567:     def __iter__(self):
Line 568:         if self.proc is None:
Line 569:             raise StopIteration
Line 570:         elif self.proc.returncode is None:
Done
Line 571:             for line in self.proc.stdout:
Line 572:                 yield self._parseLine(line)
Line 573:         else:
Line 574:             for event in self.events():


Line 605:     @classmethod
Line 606:     def _parse(cls, text):
Line 607:         return [cls._parseLine(line) for line in text.splitlines()]
Line 608: 
Line 609:     def events(self):
Done
Line 610:         out, _ = self.proc.communicate()
Line 611: 


-- 
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: 6
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-HasComments: Yes


More information about the vdsm-patches mailing list