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)
| 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( |
no test coverage detected