Browse Source

refactor(mge/distributed): remove get_free_ports func

GitOrigin-RevId: b85c4885be
tags/v1.3.0
Megvii Engine Team 4 years ago
parent
commit
10d9d77e41
4 changed files with 0 additions and 29 deletions
  1. +0
    -1
      imperative/python/megengine/distributed/__init__.py
  2. +0
    -1
      imperative/python/megengine/distributed/launcher.py
  3. +0
    -1
      imperative/python/megengine/distributed/server.py
  4. +0
    -26
      imperative/python/megengine/distributed/util.py

+ 0
- 1
imperative/python/megengine/distributed/__init__.py View File

@@ -22,4 +22,3 @@ from .group import (
from .helper import bcast_list_, make_allreduce_cb, synchronized
from .launcher import launcher
from .server import Client, Server
from .util import get_free_ports

+ 0
- 1
imperative/python/megengine/distributed/launcher.py View File

@@ -13,7 +13,6 @@ from ..core._imperative_rt.core2 import sync
from .group import group_barrier, init_process_group
from .helper import get_device_count_by_fork
from .server import Client, Server
from .util import get_free_ports


def _run_wrapped(


+ 0
- 1
imperative/python/megengine/distributed/server.py View File

@@ -17,7 +17,6 @@ from xmlrpc.server import SimpleXMLRPCServer

from ..core._imperative_rt.utils import create_mm_server
from ..utils.future import Future
from .util import get_free_ports


class Methods:


+ 0
- 26
imperative/python/megengine/distributed/util.py View File

@@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import functools
import socket
from typing import List


def get_free_ports(num: int) -> List[int]:
"""
Get one or more free ports.
"""
socks, ports = [], []
for i in range(num):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("", 0))
socks.append(sock)
ports.append(sock.getsockname()[1])
for sock in socks:
sock.close()
return ports

Loading…
Cancel
Save