make has_started check for both pid and port

this solves the issue when a user has not killed a previous server so the port of that server wasn't removed from the pid file, which would make has_started return true even if server hasn't started yet.
This commit is contained in:
Ziad-I
2024-08-13 03:12:56 +03:00
parent 3b7d44a1c6
commit 9aba274070
+2 -1
View File
@@ -231,6 +231,7 @@ class Web(bonsai.core.tool.Web):
Returns:
bool: True if the WebSocket server has started on the specified port within the maximum time limit, False otherwise.
"""
pid = ws_process.pid
max_time = 5
start = time.time()
while True:
@@ -241,7 +242,7 @@ class Web(bonsai.core.tool.Web):
try:
with open(pid_file, "r") as f:
data = json.load(f)
if port in data.values():
if data.get(str(pid)) == port:
return True
except:
pass