[docs]deffind_free_port():""" Finds an available port and returns that port number. NOTE: If this function is being used to allocate a port to Store (or indirectly via init_process_group or init_rpc), it should be used in conjuction with the `retry_on_connect_failures` decorator as there is a potential race condition where the allocated port may become unavailable before it can be used """withclosing(socket.socket(socket.AF_INET,socket.SOCK_STREAM))assock:sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)sock.bind(("localhost",0))_,port=sock.getsockname()returnport