stephenhoang commited on
Commit
0b0e589
·
1 Parent(s): 71084ac

Fix gradio queue args + keep-alive for Spaces

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -173,17 +173,26 @@ with gr.Blocks() as demo:
173
  )
174
 
175
 
176
-
177
-
178
  import os
 
 
179
  PORT = int(os.environ.get("PORT", 7860))
180
 
181
  if __name__ == "__main__":
182
- demo.queue() # không truyền kwargs để khỏi mismatch version
 
 
 
 
 
 
183
  demo.launch(
184
  server_name="0.0.0.0",
185
  server_port=PORT,
186
- ssr_mode=False,
187
  show_error=True,
188
- prevent_thread_lock=False, # giữ process sống
189
  )
 
 
 
 
 
173
  )
174
 
175
 
 
 
176
  import os
177
+ import time
178
+
179
  PORT = int(os.environ.get("PORT", 7860))
180
 
181
  if __name__ == "__main__":
182
+ # Queue: không truyền kwargs để khỏi lệch version
183
+ try:
184
+ demo.queue()
185
+ except Exception:
186
+ pass
187
+
188
+ # Launch
189
  demo.launch(
190
  server_name="0.0.0.0",
191
  server_port=PORT,
 
192
  show_error=True,
193
+ ssr_mode=False, # tránh SSR đòi Node/behavior lạ
194
  )
195
+
196
+ # Keep-alive: đảm bảo process không exit trên một số build/runtime
197
+ while True:
198
+ time.sleep(3600)