Skip to content

Commit d4b3920

Browse files
committed
update
1 parent aa4156c commit d4b3920

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/lightning/fabric/plugins/environments/lightning.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,11 @@ def teardown(self) -> None:
111111
del os.environ["WORLD_SIZE"]
112112

113113

114-
def is_port_available(port: int) -> bool:
115-
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
116-
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
117-
return s.connect_ex(("localhost", port)) != 0
118-
119-
120114
def find_free_network_port(base: int = BASE_PORT, step: int = STEP) -> int:
121115
"""Finds a free port on localhost.
122116
123117
It is useful in single-node training when we don't want to connect to a real main node but have to set the
124-
MASTER_PORT environment variable.
118+
`MASTER_PORT` environment variable.
125119
126120
"""
127121
PL_FORCE_DETERMINISTIC_PORTS = os.environ.get("PL_FORCE_DETERMINISTIC_PORTS", "0")
@@ -165,3 +159,9 @@ def find_free_network_port(base: int = BASE_PORT, step: int = STEP) -> int:
165159
f.write(f"{candidate}\n")
166160

167161
return candidate
162+
163+
164+
def is_port_available(port: int) -> bool:
165+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
166+
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
167+
return s.connect_ex(("localhost", port)) != 0

0 commit comments

Comments
 (0)