class_docstr: See documentation here
  
  https://wiki.yandex-team.ru/yatool/test/#python-acquire-ports
class_docstr_tok: ["See","documentation","here","https",":","\/\/wiki.yandex-team.ru\/yatool\/test\/","#","python-acquire-ports"]
code: def _get_port(self, port, sock_type):
      if port and self._no_random_ports():
          return port
  
      if len(self._filelocks) >= self._valid_port_count:
          raise PortManagerException(
              "All valid ports are taken ({}): {}".format(
                  self._valid_range, self._filelocks
              )
          )
  
      salt = random.randint(0, UI16MAXVAL)
      for attempt in six.moves.range(self._valid_port_count):
          probe_port = (salt + attempt) % self._valid_port_count
  
          for left, right in self._valid_range:
              if probe_port >= (right - left):
                  probe_port -= right - left
              else:
                  probe_port += left
                  break
          if not self._capture_port(probe_port, sock_type):
              continue
          return probe_port
  
      raise PortManagerException(
          "Failed to find valid port (range: {} used: {})".format(
              self._valid_range, self._filelocks
          )
      )
  
imports: import os
  import errno
  import socket
  import random
  import logging
  import platform
  import threading
  import six
label_desc: Use image node_id 13 for calling the PortManager obj's underlying member method code with example usage: obj._get_port(port, sock_type) and returns: port, probe_port