From 2c1a91241e2afe2cb30287ebcfb0ee04c7fd37a5 Mon Sep 17 00:00:00 2001 From: "psychedelicious@windows" <4822129+psychedelicious@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:11:44 +1000 Subject: [PATCH] fix(app): windows indefinite hang while finding port For some reason, I started getting this indefinite hang when the app checks if port 9090 is available. After some fiddling around, I found that adding a timeout resolves the issue. I confirmed that the util still works by starting the app on 9090, then starting a second instance. The second instance correctly saw 9090 in use and moved to 9091. --- invokeai/app/api_app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/invokeai/app/api_app.py b/invokeai/app/api_app.py index dca0bc139d..88820a0c4c 100644 --- a/invokeai/app/api_app.py +++ b/invokeai/app/api_app.py @@ -161,6 +161,7 @@ def invoke_api() -> None: # Taken from https://waylonwalker.com/python-find-available-port/, thanks Waylon! # https://github.com/WaylonWalker with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.settimeout(1) if s.connect_ex(("localhost", port)) == 0: return find_port(port=port + 1) else: