]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Update openstack/common/periodic_task
authorMichael Still <mikal@stillhq.com>
Sat, 16 Nov 2013 11:33:55 +0000 (22:33 +1100)
committerAvishay Traeger <avishay@il.ibm.com>
Sun, 24 Nov 2013 08:52:40 +0000 (10:52 +0200)
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

cinder/openstack/common/periodic_task.py

index 1693bd8c5d57cd98a245025317d1b0e61bad6a75..44faab560be531200e354c7fa350e83e330ca66b 100644 (file)
@@ -17,8 +17,9 @@ import datetime
 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
 
@@ -150,8 +151,8 @@ class _PeriodicTasksMeta(type):
                 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."""
@@ -173,7 +174,8 @@ class PeriodicTasks(object):
             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:
@@ -182,7 +184,7 @@ class PeriodicTasks(object):
                 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