def METHOD_NAME(device, stat_name):
    # From time to time, Linux returns an empty line, therefore, retry.
    TRIES = 5
    stat_path = '/sys/class/net/{}/statistics/{}'.format(device, stat_name)
    for attempt in reversed(range(TRIES)):
        try:
            with open(stat_path) as f:
                stat_val = f.read()
        except IOError as e:
            # silently ignore missing wifi stats
            if e.errno != errno.ENOENT:
                logging.debug('Could not read %s', stat_path, exc_info=True)
            return 0
        try:
            return int(stat_val)
        except ValueError:
            if stat_val != '':
                logging.warning(
                    'Could not parse stats (%s) from %s', stat_path, stat_val
                )
            logging.debug('bad %s: (%s)', stat_path, stat_val)
            if attempt == 0:
                raise