blob: d61be1efdfd0583b659c9fe3dc2b8c429cca5bd6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
from yatest.common.network import PortManager
import yql_utils
port_manager = None
def get_yql_port(service='unknown'):
global port_manager
if port_manager is None:
port_manager = PortManager()
port = port_manager.get_port()
yql_utils.log('get port for service %s: %d' % (service, port))
return port
def release_yql_port(port):
if port is None:
return
global port_manager
port_manager.release_port(port)
def get_yql_port_range(service, count):
global port_manager
if port_manager is None:
port_manager = PortManager()
port = port_manager.get_port_range(None, count)
yql_utils.log('get port range for service %s: start_port: %d, count: %d' % (service, port, count))
return port
def release_yql_port_range(start_port, count):
if start_port is None:
return
global port_manager
for port in range(start_port, start_port + count):
port_manager.release_port(port)
|