Skip to content

Commit 31333a7

Browse files
committed
check if invokeai is running before trying to update
- on windows systems, updating the .venv while invokeai is using it leads to corruption.
1 parent 2af511c commit 31333a7

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

ldm/invoke/config/invokeai_update.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
'''
55
import os
66
import platform
7+
import psutil
78
import requests
89
from rich import box, print
9-
from rich.console import Console, Group, group
10+
from rich.console import Console, group
1011
from rich.panel import Panel
1112
from rich.prompt import Prompt
1213
from rich.style import Style
13-
from rich.syntax import Syntax
14-
from rich.text import Text
1514

1615
from ldm.invoke import __version__
1716

@@ -32,6 +31,16 @@
3231
def get_versions()->dict:
3332
return requests.get(url=INVOKE_AI_REL).json()
3433

34+
def invokeai_is_running()->bool:
35+
for p in psutil.process_iter():
36+
cmdline = p.cmdline()
37+
matches = [x for x in cmdline if x.endswith('invokeai')]
38+
if matches:
39+
print(f':exclamation: [bold red]An InvokeAI instance appears to be running as process {p.pid}[/red bold]')
40+
return True
41+
return False
42+
43+
3544
def welcome(versions: dict):
3645

3746
@group()
@@ -62,6 +71,10 @@ def text():
6271

6372
def main():
6473
versions = get_versions()
74+
if invokeai_is_running():
75+
print(f':exclamation: [bold red]Please terminate all running instances of InvokeAI before updating.[/red bold]')
76+
return
77+
6578
welcome(versions)
6679

6780
tag = None

0 commit comments

Comments
 (0)