Use importlib instead of pkg_resources for ansible conf
Using importlib to read resource strings is said to be much faster than pkg_resources[1]. See if we see a performance improvement. Thanks to Clark Boylan for the suggestion. [1] https://docs.python.org/3/library/importlib.resources.html#importlib.resources.files Change-Id: I0b7d16d14989918682e137a56da7b0c65b14c336
This commit is contained in:
parent
239a4b9142
commit
341e8d8ccd
|
@ -20,8 +20,8 @@ import shutil
|
|||
import subprocess
|
||||
import sys
|
||||
import zuul.ansible
|
||||
import importlib.resources
|
||||
|
||||
from pkg_resources import resource_string
|
||||
from zuul.lib.config import get_default
|
||||
|
||||
|
||||
|
@ -160,7 +160,9 @@ class AnsibleManager:
|
|||
self.default_version = default_version
|
||||
|
||||
def load_ansible_config(self):
|
||||
c = resource_string(__name__, 'ansible-config.conf').decode()
|
||||
ref = importlib.resources.files('zuul').joinpath(
|
||||
'lib/ansible-config.conf')
|
||||
c = ref.read_bytes().decode()
|
||||
config = configparser.ConfigParser()
|
||||
config.read_string(c)
|
||||
|
||||
|
|
Loading…
Reference in New Issue