i0switch commited on
Commit
a149d1e
·
verified ·
1 Parent(s): cd4d606

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -237,16 +237,16 @@ if __name__ == "__main__":
237
 
238
  port = int(os.getenv("PORT", 7860))
239
  # ローカルでのテスト用にタイムアウトを短縮
240
- # timeout_sec = 30
241
- # poll_interval = 2
242
- #
243
- # t0 = time.time()
244
- # while not port_is_free(port):
245
- # waited = time.time() - t0
246
- # if waited >= timeout_sec:
247
- # raise RuntimeError(f"Port {port} is still busy after {timeout_sec}s")
248
- # print(f"⚠️ Port {port} busy, retrying in {poll_interval}s …")
249
- # time.sleep(poll_interval)
250
 
251
  # Hugging Face Spaces環境ではポートの競合は起こりにくいため、ポートチェックロジックを簡略化・無効化
252
  uvicorn.run(app, host="0.0.0.0", port=port, workers=1, log_level="info")
 
237
 
238
  port = int(os.getenv("PORT", 7860))
239
  # ローカルでのテスト用にタイムアウトを短縮
240
+ timeout_sec = 30
241
+ poll_interval = 2
242
+
243
+ t0 = time.time()
244
+ while not port_is_free(port):
245
+ waited = time.time() - t0
246
+ if waited >= timeout_sec:
247
+ raise RuntimeError(f"Port {port} is still busy after {timeout_sec}s")
248
+ print(f"⚠️ Port {port} busy, retrying in {poll_interval}s …")
249
+ time.sleep(poll_interval)
250
 
251
  # Hugging Face Spaces環境ではポートの競合は起こりにくいため、ポートチェックロジックを簡略化・無効化
252
  uvicorn.run(app, host="0.0.0.0", port=port, workers=1, log_level="info")