diff --git a/oslo/messaging/_drivers/base.py b/oslo/messaging/_drivers/base.py index 614552c59..15f8d32f6 100644 --- a/oslo/messaging/_drivers/base.py +++ b/oslo/messaging/_drivers/base.py @@ -15,6 +15,8 @@ import abc +import six + from oslo.messaging import exceptions @@ -22,10 +24,9 @@ class TransportDriverError(exceptions.MessagingException): """Base class for transport driver specific exceptions.""" +@six.add_metaclass(abc.ABCMeta) class IncomingMessage(object): - __metaclass__ = abc.ABCMeta - def __init__(self, listener, ctxt, message): self.conf = listener.conf self.listener = listener @@ -37,10 +38,9 @@ class IncomingMessage(object): "Send a reply or failure back to the client." +@six.add_metaclass(abc.ABCMeta) class Listener(object): - __metaclass__ = abc.ABCMeta - def __init__(self, driver, target): self.conf = driver.conf self.driver = driver @@ -51,10 +51,9 @@ class Listener(object): "Blocking until a message is pending and return IncomingMessage." +@six.add_metaclass(abc.ABCMeta) class BaseDriver(object): - __metaclass__ = abc.ABCMeta - def __init__(self, conf, url, default_exchange=None, allowed_remote_exmods=[]): self.conf = conf diff --git a/oslo/messaging/_drivers/pool.py b/oslo/messaging/_drivers/pool.py index eecc849bf..e689d678a 100644 --- a/oslo/messaging/_drivers/pool.py +++ b/oslo/messaging/_drivers/pool.py @@ -17,7 +17,10 @@ import abc import collections import threading +import six + +@six.add_metaclass(abc.ABCMeta) class Pool(object): """A thread-safe object pool. @@ -28,8 +31,6 @@ class Pool(object): Resizing is not supported. """ - __metaclass__ = abc.ABCMeta - def __init__(self, max_size=4): super(Pool, self).__init__() diff --git a/oslo/messaging/_executors/base.py b/oslo/messaging/_executors/base.py index ebf22cf0e..79ab6223e 100644 --- a/oslo/messaging/_executors/base.py +++ b/oslo/messaging/_executors/base.py @@ -16,15 +16,16 @@ import abc import logging import sys +import six + from oslo import messaging _LOG = logging.getLogger(__name__) +@six.add_metaclass(abc.ABCMeta) class ExecutorBase(object): - __metaclass__ = abc.ABCMeta - def __init__(self, conf, listener, callback): self.conf = conf self.listener = listener diff --git a/oslo/messaging/notify/notifier.py b/oslo/messaging/notify/notifier.py index e25005300..4cc025973 100644 --- a/oslo/messaging/notify/notifier.py +++ b/oslo/messaging/notify/notifier.py @@ -19,6 +19,7 @@ import abc import logging from oslo.config import cfg +import six from stevedore import named from oslo.messaging.openstack.common import timeutils @@ -39,10 +40,9 @@ _notifier_opts = [ _LOG = logging.getLogger(__name__) +@six.add_metaclass(abc.ABCMeta) class _Driver(object): - __metaclass__ = abc.ABCMeta - def __init__(self, conf, topics, transport): self.conf = conf self.topics = topics diff --git a/oslo/messaging/serializer.py b/oslo/messaging/serializer.py index d52eb831f..894f0f4a7 100644 --- a/oslo/messaging/serializer.py +++ b/oslo/messaging/serializer.py @@ -18,10 +18,12 @@ __all__ = ['Serializer', 'NoOpSerializer'] import abc +import six + +@six.add_metaclass(abc.ABCMeta) class Serializer(object): """Generic (de-)serialization definition base class.""" - __metaclass__ = abc.ABCMeta @abc.abstractmethod def serialize_entity(self, ctxt, entity):