Nir Soffer has posted comments on this change.

Change subject: virt: migration: use contextmanager for monitor
......................................................................


Patch Set 20:

(1 comment)

http://gerrit.ovirt.org/#/c/25978/20/vdsm/virt/migration.py
File vdsm/virt/migration.py:

Line 298:                                'with miguri %s', duri, muri)
Line 299: 
Line 300:             with migrationMonitor(self._vm,
Line 301:                                   startTime,
Line 302:                                   self._downtime) as 
self._monitorThread:
> I am not a fan of this indentation but it's just taste. Incidentally I woul
Setting self._monitorThread in the "as" part is surprising, while the old code 
was very clear.

How about this:

    self._monitorThread = MonitorThread(...)
    with self._monitorThread:
        do stuff

Where MonitorThread implements:

    def __enter__(self):
        self.start()
        return self

    def __exit__(self, *args):
        self.stop()

But looking around, the issue in the old code was not the try-finally, but 
having a lot of code in the try finally block.

So changing the old code to:

    self._monitorThread = MonitorThread(...)
    self._monitorThread.start()
    try:
        self.peform_migration(...)
    finally:
        self._monitorThread.stop()

Is better - it is safe and very easy to read and change.
Line 303:                 if self._vm.hasSpice and 
self._vm.conf.get('clientIp'):
Line 304:                     SPICE_MIGRATION_HANDOVER_TIME = 120
Line 305:                     
self._vm._reviveTicket(SPICE_MIGRATION_HANDOVER_TIME)
Line 306: 


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie7fcd0bedf4f30cc0bcab03339322df1fc5434e8
Gerrit-PatchSet: 20
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <[email protected]>
Gerrit-Reviewer: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Federico Simoncelli <[email protected]>
Gerrit-Reviewer: Francesco Romani <[email protected]>
Gerrit-Reviewer: Nir Soffer <[email protected]>
Gerrit-Reviewer: Vinzenz Feenstra <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to