summaryrefslogtreecommitdiffstats
path: root/wrapper.py
diff options
context:
space:
mode:
Diffstat (limited to 'wrapper.py')
-rw-r--r--wrapper.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/wrapper.py b/wrapper.py
index 65dcf3c6..3099ad5d 100644
--- a/wrapper.py
+++ b/wrapper.py
@@ -12,6 +12,7 @@
12# See the License for the specific language governing permissions and 12# See the License for the specific language governing permissions and
13# limitations under the License. 13# limitations under the License.
14 14
15import functools
15import importlib.machinery 16import importlib.machinery
16import importlib.util 17import importlib.util
17import os 18import os
@@ -21,15 +22,11 @@ def WrapperPath():
21 return os.path.join(os.path.dirname(__file__), 'repo') 22 return os.path.join(os.path.dirname(__file__), 'repo')
22 23
23 24
24_wrapper_module = None 25@functools.lru_cache(maxsize=None)
25
26
27def Wrapper(): 26def Wrapper():
28 global _wrapper_module 27 modname = 'wrapper'
29 if not _wrapper_module: 28 loader = importlib.machinery.SourceFileLoader(modname, WrapperPath())
30 modname = 'wrapper' 29 spec = importlib.util.spec_from_loader(modname, loader)
31 loader = importlib.machinery.SourceFileLoader(modname, WrapperPath()) 30 module = importlib.util.module_from_spec(spec)
32 spec = importlib.util.spec_from_loader(modname, loader) 31 loader.exec_module(module)
33 _wrapper_module = importlib.util.module_from_spec(spec) 32 return module
34 loader.exec_module(_wrapper_module)
35 return _wrapper_module