From 0d2a4b608c075daa3a4d1a1c9df01a763ae4793a Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Mon, 15 May 2023 20:57:11 +0300 Subject: load extensions' git metadata in parallel to loading the main program to save a ton of time during startup --- modules/extensions.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules/extensions.py') diff --git a/modules/extensions.py b/modules/extensions.py index bc2c0450..1053253e 100644 --- a/modules/extensions.py +++ b/modules/extensions.py @@ -1,5 +1,6 @@ import os import sys +import threading import traceback import time @@ -24,6 +25,8 @@ def active(): class Extension: + lock = threading.Lock() + def __init__(self, name, path, enabled=True, is_builtin=False): self.name = name self.path = path @@ -42,8 +45,13 @@ class Extension: if self.is_builtin or self.have_info_from_repo: return - self.have_info_from_repo = True + with self.lock: + if self.have_info_from_repo: + return + self.do_read_info_from_repo() + + def do_read_info_from_repo(self): repo = None try: if os.path.exists(os.path.join(self.path, ".git")): @@ -70,6 +78,8 @@ class Extension: print(f"Failed reading extension data from Git repository ({self.name}): {ex}", file=sys.stderr) self.remote = None + self.have_info_from_repo = True + def list_files(self, subdir, extension): from modules import scripts -- cgit v1.2.3