A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
test(cli): avoid slow refused connections when selecting ports (#11152)
Shahmir Varqha036e1110a246
diff --git a/tests/_cli/test_cli.py b/tests/_cli/test_cli.pyindex 940589eb2f..0a860c943f 100644--- a/tests/_cli/test_cli.py+++ b/tests/_cli/test_cli.py@@ -13,7 +13,6 @@ import jsonimport osimport shutilimport signal-import socketimport subprocessimport sysimport tempfile@@ -44,6 +43,7 @@ from marimo._server.workspace import ()from marimo._templates import get_versionfrom marimo._utils.env import is_env_true+from marimo._utils.net import find_free_portfrom marimo._utils.platform import is_windowsfrom marimo._utils.toml import toml_reader@@ -216,16 +216,7 @@ def _check_contents(def _get_port() -> int:- port = 2718- max_tries = 25- for _ in range(max_tries):- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:- in_use = s.connect_ex(("localhost", port)) == 0- if in_use:- port += 1- else:- return port- raise OSError("Could not find an unused port.")+ return find_free_port(2718, attempts=25, addr="127.0.0.1")def _read_toml(filepath: Path) -> dict[str, Any] | None: