chrome/test/chromedriver/util.py
def FindProbableFreePorts():
  """Get an generator returning random free ports on the system.

  Note that this function has an inherent race condition: some other process
  may bind to the port after we return it, so it may no longer be free by then.
  The workaround is to do this inside a retry loop. Do not use this function
  if there is any alternative.
  """
  # This is the range of dynamic ports. See RFC6335 page 10.
  dynamic_ports = range(49152, 65535)
  random.shuffle(dynamic_ports)

  for port in dynamic_ports:
    try:
      socket.create_connection(('127.0.0.1', port), 0.2).close()
    except socket.error:
      # If we can't connect to the port, then clearly nothing is listening on
      # it.
      yield port
  raise RuntimeError('Cannot find open port')
Get an generator returning random free ports on the system.

  Note that this function has an inherent race condition: some other process
  may bind to the port after we return it, so it may no longer be free by then.
  The workaround is to do this inside a retry loop. Do not use this function
  if there is any alternative.
  
Get an generator returning random free ports on the system.
Note that this function has an inherent race condition: some other process
may bind to the port after we return it, so it may no longer be free by then.
The workaround is to do this inside a retry loop. Do not use this function
if there is any alternative.
Get an generator returning random free ports on the system . Note that this function has an inherent race condition : some other process may bind to the port after we return it so it may no longer be free by then . The workaround is to do this inside a retry loop . Do not use this function if there is any alternative .
def FindProbableFreePorts():
  dynamic_ports = range(49152, 65535)
  random.shuffle(dynamic_ports)
  for port in dynamic_ports:
    try:
      socket.create_connection(('127.0.0.1', port), 0.2).close()
    except socket.error:
      yield port
  raise RuntimeError('Cannot find open port')
def FindProbableFreePorts ( ) : dynamic_ports = range ( 49152 , 65535 ) random . shuffle ( dynamic_ports ) for port in dynamic_ports : try : socket . create_connection ( ( '127.0.0.1' , port ) , 0.2 ) . close ( ) except socket . error : yield port raise RuntimeError ( 'Cannot find open port' )
Get an generator returning random free ports on the system.
Get an generator returning random free ports on the system .
"""Get an generator returning random free ports on the system.

  Note that this function has an inherent race condition: some other process
  may bind to the port after we return it, so it may no longer be free by then.
  The workaround is to do this inside a retry loop. Do not use this function
  if there is any alternative.
  """ # This is the range of dynamic ports. See RFC6335 page 10. # If we can't connect to the port, then clearly nothing is listening on # it.