Skip to content

Commit

Permalink
Update openstack/common/periodic_task
Browse files Browse the repository at this point in the history
The following commits are in this update:

1771a77 Adjust import order according to PEP8 imports rule
4bfb7a2 Apply six for metaclass
0ea069e Removed calls to locals()

Change-Id: Ied20ce735af79b52e7674a3dfe3b097b84b61533
  • Loading branch information
mikalstill authored and avishay-traeger committed Nov 24, 2013
1 parent 88e6883 commit cb68891
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cinder/openstack/common/periodic_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import time

from oslo.config import cfg
import six

from cinder.openstack.common.gettextutils import _
from cinder.openstack.common.gettextutils import _ # noqa
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils

Expand Down Expand Up @@ -150,8 +151,8 @@ def __init__(cls, names, bases, dict_):
cls._periodic_last_run[name] = task._periodic_last_run


@six.add_metaclass(_PeriodicTasksMeta)
class PeriodicTasks(object):
__metaclass__ = _PeriodicTasksMeta

def run_periodic_tasks(self, context, raise_on_error=False):
"""Tasks to be run at a periodic interval."""
Expand All @@ -173,7 +174,8 @@ def run_periodic_tasks(self, context, raise_on_error=False):
if spacing is not None:
idle_for = min(idle_for, spacing)

LOG.debug(_("Running periodic task %(full_task_name)s"), locals())
LOG.debug(_("Running periodic task %(full_task_name)s"),
{"full_task_name": full_task_name})
self._periodic_last_run[task_name] = timeutils.utcnow()

try:
Expand All @@ -182,7 +184,7 @@ def run_periodic_tasks(self, context, raise_on_error=False):
if raise_on_error:
raise
LOG.exception(_("Error during %(full_task_name)s: %(e)s"),
locals())
{"full_task_name": full_task_name, "e": e})
time.sleep(0)

return idle_for

0 comments on commit cb68891

Please sign in to comment.