diff --git a/salt/utils/event.py b/salt/utils/event.py index 73ffc18469..7526e40ac5 100644 --- a/salt/utils/event.py +++ b/salt/utils/event.py @@ -595,10 +595,13 @@ class ReactWrap(object): ''' Create a wrapper that executes low data for the reaction system ''' + # class-wide cache of clients + client_cache = None + def __init__(self, opts): self.opts = opts - - self.cachedict = salt.utils.cache.CacheDict(opts['reactor_refresh_interval']) + if ReactWrap.client_cache is None: + ReactWrap.client_cache = salt.utils.cache.CacheDict(opts['reactor_refresh_interval']) def run(self, low): ''' @@ -621,25 +624,25 @@ class ReactWrap(object): ''' Wrap LocalClient for running :ref:`execution modules ` ''' - if 'local' not in self.cachedict: - self.cachedict['local'] = salt.client.LocalClient(self.opts['conf_file']) - return self.cachedict['local'].cmd_async(*args, **kwargs) + if 'local' not in self.client_cache: + self.client_cache['local'] = salt.client.LocalClient(self.opts['conf_file']) + return self.client_cache['local'].cmd_async(*args, **kwargs) def runner(self, fun, **kwargs): ''' Wrap RunnerClient for executing :ref:`runner modules ` ''' - if 'runner' not in self.cachedict: - self.cachedict['runner'] = salt.runner.RunnerClient(self.opts) - return self.cachedict['runner'].low(fun, kwargs) + if 'runner' not in self.client_cache: + self.client_cache['runner'] = salt.runner.RunnerClient(self.opts) + return self.client_cache['runner'].low(fun, kwargs) def wheel(self, fun, **kwargs): ''' Wrap Wheel to enable executing :ref:`wheel modules ` ''' - if 'wheel' not in self.cachedict: - self.cachedict['wheel'] = salt.wheel.Wheel(self.opts) - return self.cachedict['wheel'].call_func(fun, **kwargs) + if 'wheel' not in self.client_cache: + self.client_cache['wheel'] = salt.wheel.Wheel(self.opts) + return self.client_cache['wheel'].call_func(fun, **kwargs) class StateFire(object):