lang03383 commited on
Commit
84a10f2
1 Parent(s): 2f9a7f2

Update sd_yun/launch_en.py

Browse files
Files changed (1) hide show
  1. sd_yun/launch_en.py +19 -1
sd_yun/launch_en.py CHANGED
@@ -9,6 +9,16 @@ import subprocess
9
  import cloudpickle as pickle
10
  from datetime import timedelta
11
  from IPython.display import clear_output
 
 
 
 
 
 
 
 
 
 
12
 
13
 
14
  # Setup Env
@@ -113,7 +123,15 @@ with tunnel:
113
  commandline_arguments += ' --xformers'
114
  else:
115
  commandline_arguments += ' --disable-xformers --opt-sdp-attention --cuda-stream --pin-shared-memory'
116
- get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python upload.py &> /dev/null &')
 
 
 
 
 
 
 
 
117
  get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
118
 
119
  start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
 
9
  import cloudpickle as pickle
10
  from datetime import timedelta
11
  from IPython.display import clear_output
12
+ import psutil
13
+ def is_process_running(script_name):
14
+ """检查脚本是否正在运行"""
15
+ for proc in psutil.process_iter(['pid', 'name', 'cmdline']):
16
+ try:
17
+ if proc.info['name'] == 'python' and script_name in ' '.join(proc.info['cmdline']):
18
+ return True
19
+ except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
20
+ pass
21
+ return False
22
 
23
 
24
  # Setup Env
 
123
  commandline_arguments += ' --xformers'
124
  else:
125
  commandline_arguments += ' --disable-xformers --opt-sdp-attention --cuda-stream --pin-shared-memory'
126
+ process_name = "python upload.py"
127
+ try:
128
+ subprocess.check_output(["pgrep", "-f", process_name])
129
+ print("Upload 脚本已经在运行中")
130
+ except subprocess.CalledProcessError:
131
+ # 脚本没有运行,启动它
132
+ print("启动 Upload 脚本")
133
+ subprocess.Popen(["nohup", "python", "./upload.py", ">", "/dev/null", "2>&1", "&"])
134
+ # get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python upload.py &> /dev/null &')
135
  get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
136
 
137
  start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())