load extensions' git metadata in parallel to loading the main program to save a ton of time during startup

This commit is contained in:
AUTOMATIC
2023-05-15 20:57:11 +03:00
parent 0d3a80e269
commit 0d2a4b608c
3 changed files with 26 additions and 3 deletions

View File

@@ -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