Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
Francesco Romani has posted comments on this change. Change subject: schedule: Introduce scheduling library .. Patch Set 3: Rerun-Hooks: all -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr KliczewskiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: Piotr Kliczewski Gerrit-Reviewer: Yaniv Bronhaim Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
automat...@ovirt.org has posted comments on this change. Change subject: schedule: Introduce scheduling library .. Patch Set 3: * #1279950::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1279950::OK, public bug * Check Product::#1279950::OK, Correct product Red Hat Enterprise Virtualization Manager * Check TM::#1279950::OK, correct target milestone ovirt-3.5.7 * Check merged to previous::OK, change not open on any previous branch -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr KliczewskiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: Piotr Kliczewski Gerrit-Reviewer: Yaniv Bronhaim Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
automat...@ovirt.org has posted comments on this change. Change subject: schedule: Introduce scheduling library .. Patch Set 3: * #1279950::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1279950::OK, public bug * Check Product::#1279950::OK, Correct product Red Hat Enterprise Virtualization Manager * Check TM::#1279950::OK, correct target milestone ovirt-3.5.7 * Check merged to previous::OK, change not open on any previous branch -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr KliczewskiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: Piotr Kliczewski Gerrit-Reviewer: Yaniv Bronhaim Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
automat...@ovirt.org has posted comments on this change. Change subject: schedule: Introduce scheduling library .. Patch Set 4: * #1279950::Update tracker: OK * Set MODIFIED::bug 1279950#1279950IGNORE, not oVirt classification but Red Hat -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr KliczewskiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: Piotr Kliczewski Gerrit-Reviewer: Yaniv Bronhaim Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
Francesco Romani has submitted this change and it was merged. Change subject: schedule: Introduce scheduling library .. schedule: Introduce scheduling library This moudule provides a Scheduler class scheduling execution of callables on a background thread. This should be part of the new scalable vm sampling implemntation. See the module docstring and tests for usage examples. Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Signed-off-by: Nir SofferReviewed-on: http://gerrit.ovirt.org/29607 Reviewed-by: Dan Kenigsberg Reviewed-by: Francesco Romani Signed-off-by: pkliczewski Bug-Url: https://bugzilla.redhat.com/1279950 Reviewed-on: https://gerrit.ovirt.org/48195 Continuous-Integration: Francesco Romani --- M debian/vdsm-python.install M lib/vdsm/Makefile.am A lib/vdsm/schedule.py M tests/Makefile.am A tests/scheduleTests.py M vdsm.spec.in 6 files changed, 441 insertions(+), 0 deletions(-) Approvals: Piotr Kliczewski: Verified Francesco Romani: Looks good to me, approved; Passed CI tests -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr Kliczewski Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: Piotr Kliczewski Gerrit-Reviewer: Yaniv Bronhaim Gerrit-Reviewer: automat...@ovirt.org ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
Francesco Romani has posted comments on this change. Change subject: schedule: Introduce scheduling library .. Patch Set 3: CI jobs run manually -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr KliczewskiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: Piotr Kliczewski Gerrit-Reviewer: Yaniv Bronhaim Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
Francesco Romani has posted comments on this change. Change subject: schedule: Introduce scheduling library .. Patch Set 3: Continuous-Integration+1 -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr KliczewskiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: Piotr Kliczewski Gerrit-Reviewer: Yaniv Bronhaim Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
Piotr Kliczewski has posted comments on this change. Change subject: schedule: Introduce scheduling library .. Patch Set 2: Verified+1 Verified be performance team. -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr KliczewskiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: Piotr Kliczewski Gerrit-Reviewer: Yaniv Bronhaim Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
Hello Dan Kenigsberg, Francesco Romani, I'd like you to do a code review. Please visit https://gerrit.ovirt.org/48195 to review the following change. Change subject: schedule: Introduce scheduling library .. schedule: Introduce scheduling library This moudule provides a Scheduler class scheduling execution of callables on a background thread. This should be part of the new scalable vm sampling implemntation. See the module docstring and tests for usage examples. Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Signed-off-by: Nir SofferReviewed-on: http://gerrit.ovirt.org/29607 Reviewed-by: Dan Kenigsberg Reviewed-by: Francesco Romani Signed-off-by: pkliczewski Bug-Url: https://bugzilla.redhat.com/1279950 --- M debian/vdsm-python.install M lib/vdsm/Makefile.am A lib/vdsm/schedule.py M tests/Makefile.am A tests/scheduleTests.py M vdsm.spec.in 6 files changed, 441 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/95/48195/2 diff --git a/debian/vdsm-python.install b/debian/vdsm-python.install index 3488c6e..c10381e 100644 --- a/debian/vdsm-python.install +++ b/debian/vdsm-python.install @@ -16,6 +16,7 @@ ./usr/lib/python2.7/dist-packages/vdsm/password.py ./usr/lib/python2.7/dist-packages/vdsm/profile.py ./usr/lib/python2.7/dist-packages/vdsm/qemuimg.py +./usr/lib/python2.7/dist-packages/vdsm/schedule.py ./usr/lib/python2.7/dist-packages/vdsm/sslutils.py ./usr/lib/python2.7/dist-packages/vdsm/taskset.py ./usr/lib/python2.7/dist-packages/vdsm/tool/__init__.py diff --git a/lib/vdsm/Makefile.am b/lib/vdsm/Makefile.am index 1922b91..6c8fb0f 100644 --- a/lib/vdsm/Makefile.am +++ b/lib/vdsm/Makefile.am @@ -35,6 +35,7 @@ password.py \ profile.py \ qemuimg.py \ + schedule.py \ SecureXMLRPCServer.py \ sslutils.py \ sysctl.py \ diff --git a/lib/vdsm/schedule.py b/lib/vdsm/schedule.py new file mode 100644 index 000..92fcc83 --- /dev/null +++ b/lib/vdsm/schedule.py @@ -0,0 +1,220 @@ +# +# Copyright 2014 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +""" +This module provides a Scheduler class scheduling execution of +a callable on a background thread. + +To use a scheduler, create an instance and start it: + +scheduler = schedule.Scheduler() +scheduler.start() + +The scheduler default clock is time.time. This clock is not monotonic, which +may cause scheduled calls to fire too early or too late if the system time is +modified by the administrator or by ntp service. If you care about this and can +live with utils.monotonic_time's lower resolution, you can use it as the clock. + +scheduler = schedule.Scheduler(clock=utils.monotonic_time) + +When you want to schedule some callable: + +def task(): +print '30 seconds passed' + +scheduler.schedule(30.0, task) + +Task will be called after 30.0 seconds on the scheduler background thread. + +If you need to cancel a scheduled call, keep the ScheduledCall object returned +from Scheduler.schedule(), and cancel the task: + +scheduled_call = scheduler.schedule(30.0, call) +... +scheduled_call.cancel() + +Finally, when the scheduler is not needed any more: + +scheduler.stop() + +This will cancel any pending calls and terminate the scheduler thread. +""" + +import heapq +import logging +import threading +import time + +from . import utils + + +class Scheduler(object): +""" +Schedule calls for future execution in a background thread. + +This class is thread safe; multiple threads can schedule calls or cancel +the scheduler. +""" + +DEFAULT_DELAY = 30.0 # Used if no call are scheduled + +_log = logging.getLogger("Scheduler") + +def __init__(self, name="Scheduler", clock=time.time): +""" +Initialize a scheduler. + +Arguments: + name Used as sheculer thread name + clock Callable returning current time (defualt time.time) +""" +self._name = name +self._clock = clock +self._cond =
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
automat...@ovirt.org has posted comments on this change. Change subject: schedule: Introduce scheduling library .. Patch Set 2: -Verified * #1279950::Update tracker: OK * Check Bug-Url::OK * Check Public Bug::#1279950::OK, public bug * Check Product::#1279950::OK, Correct product Red Hat Enterprise Virtualization Manager * Check TM::#1279950::OK, correct target milestone ovirt-3.5.7 * Check merged to previous::OK, change not open on any previous branch -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr KliczewskiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
Francesco Romani has posted comments on this change. Change subject: schedule: Introduce scheduling library .. Patch Set 2: Code-Review+2 looks fine. New code, well covered by tests, very little chance to break something :) -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr KliczewskiGerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Francesco Romani Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: Piotr Kliczewski Gerrit-Reviewer: Yaniv Bronhaim Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[ovirt-3.5]: schedule: Introduce scheduling library
automat...@ovirt.org has posted comments on this change. Change subject: schedule: Introduce scheduling library .. Patch Set 1: Verified-1 * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::ERROR, At least one bug-url is required for the stable branch * Check merged to previous::OK, change not open on any previous branch -- To view, visit https://gerrit.ovirt.org/48195 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie3764806d93bd37c3b5924080eb5ae4d29e4f4e0 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Piotr KliczewskiGerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches