mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-04 19:55:00 +00:00
refactor: Synchronize slow imports and improve error handling
This commit is contained in:
parent
f54b6860db
commit
b4389f98fb
1 changed files with 4 additions and 10 deletions
|
@ -686,7 +686,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
if args.exit:
|
if args.exit:
|
||||||
return
|
return
|
||||||
|
|
||||||
launch_slow_imports_thread()
|
check_and_load_imports(io)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
@ -704,15 +704,9 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
coder.show_announcements()
|
coder.show_announcements()
|
||||||
|
|
||||||
|
|
||||||
def launch_slow_imports_thread():
|
|
||||||
thread = threading.Thread(target=check_and_load_imports)
|
|
||||||
thread.daemon = True
|
|
||||||
thread.start()
|
|
||||||
|
|
||||||
|
|
||||||
def check_and_load_imports():
|
def check_and_load_imports(io):
|
||||||
import json
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
installs_file = Path.home() / ".aider" / "installs.json"
|
installs_file = Path.home() / ".aider" / "installs.json"
|
||||||
key = (__version__, sys.executable)
|
key = (__version__, sys.executable)
|
||||||
|
@ -729,13 +723,13 @@ def check_and_load_imports():
|
||||||
installs[str(key)] = True
|
installs[str(key)] = True
|
||||||
installs_file.parent.mkdir(parents=True, exist_ok=True)
|
installs_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
with open(installs_file, "w") as f:
|
with open(installs_file, "w") as f:
|
||||||
json.dump(installs, f)
|
json.dump(installs, f, indent=4)
|
||||||
else:
|
else:
|
||||||
thread = threading.Thread(target=load_slow_imports)
|
thread = threading.Thread(target=load_slow_imports)
|
||||||
thread.daemon = True
|
thread.daemon = True
|
||||||
thread.start()
|
thread.start()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error in check_and_load_imports: {e}", file=sys.stderr)
|
io.tool_warning(f"Error in check_and_load_imports: {e}", file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def load_slow_imports():
|
def load_slow_imports():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue