File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
src/lightning/fabric/plugins/environments Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff 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-
120114def 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
You can’t perform that action at this time.
0 commit comments