未验证 提交 0df2995d 编写于 作者: L Lukáš Doktor

Merging pull request 2754

Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>

* https://github.com/avocado-framework/avocado:
  avocado.utils.network: introduce default port values for find_free_port()
...@@ -48,14 +48,15 @@ def is_port_free(port, address): ...@@ -48,14 +48,15 @@ def is_port_free(port, address):
return free return free
def find_free_port(start_port, end_port, address="localhost", sequent=True): def find_free_port(start_port=1024, end_port=65535, address="localhost", sequent=True):
""" """
Return a host free port in the range [start_port, end_port]. Return a host free port in the range [start_port, end_port].
:param start_port: header of candidate port range :param start_port: header of candidate port range, defaults to 1024
:param end_port: ender of candidate port range :param end_port: ender of candidate port range, defaults to 65535
:param sequent: Find port sequentially, random order if it's False :param sequent: Find port sequentially, random order if it's False
:param address: Socket address to bind or connect :param address: Socket address to bind or connect
:rtype: int or None if no free port found
""" """
port_range = range(start_port, end_port) port_range = range(start_port, end_port)
if not sequent: if not sequent:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册