import socket import uuid from eventlet.green import subprocess from oslo.config import cfg from oslo.utils import excutils from neutron.common import constants as q_const from neutron.openstack.common import lockutils from neutron.openstack.common import log as logging TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" LOG = logging.getLogger(__name__) SYNCHRONIZED_PREFIX = 'neutron-' synchronized = lockutils.synchronized_with_prefix(SYNCHRONIZED_PREFIX) class cache_method_results(object): """This decorator is intended for object methods only.""" def __init__(self, func): self.func = func functools.update_wrapper(self, func) self._first_call = True self._not_cached = object() def _get_from_cache(self, target_self, *args, **kwargs): func_name = "%(module)s.%(class)s.%(func_name)s" % { 'module': target_self.__module__, 'class': target_self.__class__.__name__, 'func_name': self.func.__name__,
import logging as std_logging import os import signal import socket from eventlet.green import subprocess from oslo.config import cfg from neutron.common import constants as q_const from neutron.openstack.common import lockutils from neutron.openstack.common import log as logging TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" LOG = logging.getLogger(__name__) synchronized = lockutils.synchronized_with_prefix('neutron-') def read_cached_file(filename, cache_info, reload_func=None): """Read from a file if it has been modified. :param cache_info: dictionary to hold opaque cache. :param reload_func: optional function to be called with data when file is reloaded due to a modification. :returns: data from file """ mtime = os.path.getmtime(filename) if not cache_info or mtime != cache_info.get('mtime'): LOG.debug(_("Reloading cached file %s"), filename)
import uuid from eventlet.green import subprocess from oslo.config import cfg from oslo.utils import excutils from neutron.common import constants as q_const from neutron.openstack.common import lockutils from neutron.openstack.common import log as logging TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" LOG = logging.getLogger(__name__) SYNCHRONIZED_PREFIX = 'neutron-' synchronized = lockutils.synchronized_with_prefix(SYNCHRONIZED_PREFIX) class cache_method_results(object): """This decorator is intended for object methods only.""" def __init__(self, func): self.func = func functools.update_wrapper(self, func) self._first_call = True self._not_cached = object() def _get_from_cache(self, target_self, *args, **kwargs): func_name = "%(module)s.%(class)s.%(func_name)s" % { 'module': target_self.__module__, 'class': target_self.__class__.__name__,
import os import signal import socket from eventlet.green import subprocess from oslo.config import cfg from neutron.common import constants as q_const from neutron.openstack.common import lockutils from neutron.openstack.common import log as logging TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" LOG = logging.getLogger(__name__) synchronized = lockutils.synchronized_with_prefix('neutron-') def read_cached_file(filename, cache_info, reload_func=None): """Read from a file if it has been modified. :param cache_info: dictionary to hold opaque cache. :param reload_func: optional function to be called with data when file is reloaded due to a modification. :returns: data from file """ mtime = os.path.getmtime(filename) if not cache_info or mtime != cache_info.get('mtime'): LOG.debug(_("Reloading cached file %s"), filename)