diff --git a/pocket_ic/pocket_ic_server.py b/pocket_ic/pocket_ic_server.py index e56c7a4..2da42a6 100644 --- a/pocket_ic/pocket_ic_server.py +++ b/pocket_ic/pocket_ic_server.py @@ -120,14 +120,14 @@ def set_blob_store_entry(self, blob: bytes, compression: Optional[str]) -> str: return response.text def _get_url(self, port_file_path: int) -> str: - stop_at = time.time() + 10 # Wait for the ready file for 10 seconds + stop_at = time.time() + 10 # Wait for the port file for 10 seconds while True: if os.path.isfile(port_file_path): with open(port_file_path, "r", encoding="utf-8") as port_file: - port = port_file.readline().strip() - if port: - return f"http://127.0.0.1:{port}" + port = port_file.readline() + if "\n" in port: + return f"http://127.0.0.1:{port.strip()}" time.sleep(0.02) # wait for 20ms