MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / has_started

Method has_started

src/bonsai/bonsai/tool/web.py:231–256  ·  view source on GitHub ↗

Check if the WebSocket server has started on the specified port. this method continuously checks for the existence of the WebSocket server's process ID (PID) in the running_pid JSON file. It waits for a maximum of 5 seconds before returning False. :param port: The

(cls, port: int)

Source from the content-addressed store, hash-verified

229
230 @classmethod
231 def has_started(cls, port: int) -> bool:
232 """
233 Check if the WebSocket server has started on the specified port.
234
235 this method continuously checks for the existence of the WebSocket server's process ID (PID) in the running_pid JSON file.
236 It waits for a maximum of 5 seconds before returning False.
237
238 :param port: The port number on which the WebSocket server is expected to be running.
239
240 :return: bool: True if the WebSocket server has started on the specified port within the maximum time limit, False otherwise.
241 """
242 pid = ws_process.pid
243 max_time = 5
244 start = time.time()
245 while True:
246 if time.time() - start > max_time:
247 return False
248 pid_file = tool.Blender.get_data_dir_path("webui") / "running_pid.json"
249 try:
250 with open(pid_file, "r") as f:
251 data = json.load(f)
252 if data.get(str(pid)) == port:
253 return True
254 except:
255 pass
256 time.sleep(0.1)
257
258 @classmethod
259 def send_webui_data(

Callers 1

connect_websocket_serverFunction · 0.80

Calls 4

get_data_dir_pathMethod · 0.80
openFunction · 0.50
loadMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected