parameters: (adb_cmd)
docstring: Gets the device list from adb.
  
    We use an alarm in this function to avoid deadlocking from an external
    dependency.
  
    Args:
      adb_cmd: binary to run adb
  
    Returns:
      list of devices or an empty list on timeout
docstring_summary: Gets the device list from adb.
docstring_tokens: Gets the device list from adb .
function: def GetAttachedDevices(adb_cmd):
    """Gets the device list from adb.
  
    We use an alarm in this function to avoid deadlocking from an external
    dependency.
  
    Args:
      adb_cmd: binary to run adb
  
    Returns:
      list of devices or an empty list on timeout
    """
    signal.alarm(2)
    try:
      out, err = subprocess.Popen([adb_cmd, 'devices'],
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE).communicate()
      if err:
        logging.warning('adb device error %s', err.strip())
      return re.findall('^(\\S+)\tdevice$', out, re.MULTILINE)
    except TimeoutException:
      logging.warning('"adb devices" command timed out')
      return []
    except (IOError, OSError):
      logging.exception('Exception from "adb devices"')
      return []
    finally:
      signal.alarm(0)
function_tokens: def GetAttachedDevices ( adb_cmd ) : signal . alarm ( 2 ) try : out , err = subprocess . Popen ( [ adb_cmd , 'devices' ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) . communicate ( ) if err : logging . warning ( 'adb device error %s' , err . strip ( ) ) return re . findall ( '^(\\S+)\tdevice$' , out , re . MULTILINE ) except TimeoutException : logging . warning ( '"adb devices" command timed out' ) return [ ] except ( IOError , OSError ) : logging . exception ( 'Exception from "adb devices"' ) return [ ] finally : signal . alarm ( 0 )