Skip to content

Commit 2c1a912

Browse files
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.
1 parent 84f136e commit 2c1a912

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

invokeai/app/api_app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def find_port(port: int) -> int:
161161
# Taken from https://waylonwalker.com/python-find-available-port/, thanks Waylon!
162162
# https://github.com/WaylonWalker
163163
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
164+
s.settimeout(1)
164165
if s.connect_ex(("localhost", port)) == 0:
165166
return find_port(port=port + 1)
166167
else:

0 commit comments

Comments
 (0)