mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Don't instantiate the file_client every time
This commit is contained in:
parent
c6069520f1
commit
f6c592c7a1
1 changed files with 6 additions and 4 deletions
|
@ -54,6 +54,9 @@ class SaltCacheLoader(BaseLoader):
|
|||
Templates are cached like regular salt states
|
||||
and only loaded once per loader instance.
|
||||
'''
|
||||
|
||||
_file_client = None
|
||||
|
||||
def __init__(self, opts, saltenv='base', encoding='utf-8',
|
||||
pillar_rend=False):
|
||||
self.opts = opts
|
||||
|
@ -69,7 +72,6 @@ class SaltCacheLoader(BaseLoader):
|
|||
self.searchpath = [os.path.join(opts['cachedir'], 'files', saltenv)]
|
||||
log.debug('Jinja search path: %s', self.searchpath)
|
||||
self.cached = []
|
||||
self._file_client = None
|
||||
# Instantiate the fileclient
|
||||
self.file_client()
|
||||
|
||||
|
@ -77,10 +79,10 @@ class SaltCacheLoader(BaseLoader):
|
|||
'''
|
||||
Return a file client. Instantiates on first call.
|
||||
'''
|
||||
if not self._file_client:
|
||||
self._file_client = salt.fileclient.get_file_client(
|
||||
if not SaltCacheLoader._file_client:
|
||||
SaltCacheLoader._file_client = salt.fileclient.get_file_client(
|
||||
self.opts, self.pillar_rend)
|
||||
return self._file_client
|
||||
return SaltCacheLoader._file_client
|
||||
|
||||
def cache_file(self, template):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue