Exemplo n.º 1
0
def _check_result(cache_map: AbstractConcCache, q: Tuple[str, ...],
                  subchash: Optional[str], minsize: int) -> Tuple[bool, bool]:
    """
    Check for result status while validating calculation
    status. In case of an error an Exception can be thrown.

    return:
    2-tuple ["has min. acceptable result", "is finished"]
    Return True if a specific concordance calculation
    has not reached a minimal viewable size yet.
    Otherwise it returns False (= we can show a partial
    result).

    In case the calculation finished due to an error
    the function throws a ConcCalculationStatusException.
    """
    status = cache_map.get_calc_status(subchash, q)
    if status is None:
        cache_map.del_full_entry(subchash, q)
        raise ConcCalculationStatusException(
            f'Missing status information for ({subchash}, {q}).')
    err = status.test_error(TASK_TIME_LIMIT)
    if err is not None:
        cache_map.del_full_entry(subchash, q)
        raise err
    return not status.has_some_result(minsize=minsize), status.finished
Exemplo n.º 2
0
def _check_result(cache_map: AbstractConcCache, q: Tuple[str, ...],
                  subchash: Optional[str], minsize: int) -> Tuple[bool, bool]:
    """
    Check for result status while validating calculation
    status. In case of an error an Exception can be thrown.
    It is perfectly fine to not find an entry for some
    subchash+q combination (in such case, False, False is returned).

    return:
    2-tuple ["has min. acceptable result", "is finished"]
    Return True if a specific concordance calculation
    has not reached a minimal viewable size yet.
    Otherwise it returns False (= we can show a partial
    result).

    In case the calculation finished due to an error
    the function throws a ConcCalculationStatusException.
    """
    status = cache_map.get_calc_status(subchash, q)
    if status is None:
        return False, False
    status.check_for_errors(TASK_TIME_LIMIT)
    if status.error is not None:
        cache_map.del_full_entry(subchash, q)
        raise status.error
    return status.has_some_result(minsize=minsize), status.finished