def _load_tasks_file(task_id, path, batch):
    """
    :type task_id: vulyk.models.task_types.AbstractTaskType
    :type path: str | unicode
    :param batch: Batch ID tasks should be loaded into
    :type batch: str | unicode

    :return: Number of stored tasks
    :rtype: int
    """
    i = 0
    bunch_size = 100

    def _safe_load(fl):
        """
        :type fl: file
        :rtype: __generator[dict]
        """
        l = lambda s: json.loads(s) if len(s.strip()) > 0 else {}

        return ifilter(None, imap(l, fl))

    try:
        with open_anything(path)(path, 'rb') as f:
            for chunk in chunked(_safe_load(f), bunch_size):
                task_id.import_tasks(chunk, batch)

                i += len(chunk)
                echo('{0:d} tasks processed'.format(i))
    except ValueError as e:
        echo('Error while decoding json in {0}: {1}'.format(path, e))
    except __HOLE__ as e:
        echo('Got IO error when tried to decode {0}: {1}'.format(path, e))

    echo('Finished loading {0:d} tasks'.format(i))

    return i
dataset/ETHPy150Open mrgambal/vulyk/vulyk/cli/db.py/_load_tasks_file