Freak-ppa commited on
Commit
90da18f
·
verified ·
1 Parent(s): 64eb3b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -84,7 +84,7 @@ def check_server_ready():
84
 
85
 
86
  queue_reqs = set()
87
-
88
 
89
  @spaces.GPU(duration=240)
90
  def generate_image(prompt, image):
@@ -97,10 +97,13 @@ def generate_image(prompt, image):
97
 
98
  queue_reqs.add(prefix_filename)
99
  process = None
 
100
  try:
101
- # Запускаем скрипт как подпроцесс
102
- process = subprocess.Popen([sys.executable, COMF_PATH, "--listen", "127.0.0.1"])
103
- logger.debug(f'Subprocess started with PID: {process.pid}')
 
 
104
 
105
  # Ожидание запуска сервера
106
  for _ in range(20): # Максимум 20 секунд ожидания
@@ -139,6 +142,7 @@ def generate_image(prompt, image):
139
  process.wait(timeout=5)
140
  except subprocess.TimeoutExpired:
141
  process.kill()
 
142
 
143
 
144
  if __name__ == "__main__":
 
84
 
85
 
86
  queue_reqs = set()
87
+ process_started = False
88
 
89
  @spaces.GPU(duration=240)
90
  def generate_image(prompt, image):
 
97
 
98
  queue_reqs.add(prefix_filename)
99
  process = None
100
+ global process_started
101
  try:
102
+ if not process_started:
103
+ process_started = True
104
+ # Запускаем скрипт как подпроцесс
105
+ process = subprocess.Popen([sys.executable, COMF_PATH, "--listen", "127.0.0.1"])
106
+ logger.debug(f'Subprocess started with PID: {process.pid}')
107
 
108
  # Ожидание запуска сервера
109
  for _ in range(20): # Максимум 20 секунд ожидания
 
142
  process.wait(timeout=5)
143
  except subprocess.TimeoutExpired:
144
  process.kill()
145
+ process_started = False
146
 
147
 
148
  if __name__ == "__main__":