Ejemplo n.º 1
0
def get_log_path():
    '''
    Requests the logging path to the external python library (that calls
    the bindings-common).
    :return: The path where to store the logs.
    '''
    if __debug__:
        logger.debug('Requesting log path')
    log_path = compss.get_logging_path()
    if __debug__:
        logger.debug('Log path received: %s' % log_path)
    return log_path
Ejemplo n.º 2
0
def c_extension_link(in_queue, out_queue, redirect_std, out_file_name,
                     err_file_name):
    # type: (Queue, Queue, bool, str, str) -> None
    """ Main C extension process.

    :param in_queue: Queue to receive messages.
    :param out_queue: Queue to send messages.
    :param redirect_std: Decide whether to store the stdout and stderr into
                         files or not.
    :param out_file_name: File where to store the stdout (only required if
                          redirect_std is True).
    :param err_file_name: File where to store the stderr (only required if
                          redirect_std is True).
    :return: None
    """
    # Import C extension within the external process
    import compss

    with ipython_std_redirector(out_file_name, err_file_name) \
            if redirect_std else not_std_redirector():
        alive = True
        while alive:
            message = in_queue.get()
            command = message[0]
            parameters = []  # type: list
            if len(message) > 0:
                parameters = list(message[1:])
            if command == START:
                compss.start_runtime()
            elif command == SET_DEBUG:
                compss.set_debug(*parameters)
            elif command == STOP:
                compss.stop_runtime(*parameters)
                alive = False
            elif command == CANCEL_TASKS:
                compss.cancel_application_tasks(*parameters)
            elif command == ACCESSED_FILE:
                accessed = compss.accessed_file(*parameters)
                out_queue.put(accessed)
            elif command == OPEN_FILE:
                compss_name = compss.open_file(*parameters)
                out_queue.put(compss_name)
            elif command == CLOSE_FILE:
                compss.close_file(*parameters)
            elif command == DELETE_FILE:
                result = compss.delete_file(*parameters)
                out_queue.put(result)
            elif command == GET_FILE:
                compss.get_file(*parameters)
            elif command == GET_DIRECTORY:
                compss.get_directory(*parameters)
            elif command == BARRIER:
                compss.barrier(*parameters)
            elif command == BARRIER_GROUP:
                exception_message = compss.barrier_group(*parameters)
                out_queue.put(exception_message)
            elif command == OPEN_TASK_GROUP:
                compss.open_task_group(*parameters)
            elif command == CLOSE_TASK_GROUP:
                compss.close_task_group(*parameters)
            elif command == GET_LOGGING_PATH:
                log_path = compss.get_logging_path()
                out_queue.put(log_path)
            elif command == GET_NUMBER_OF_RESOURCES:
                num_resources = compss.get_number_of_resources(*parameters)
                out_queue.put(num_resources)
            elif command == REQUEST_RESOURCES:
                compss.request_resources(*parameters)
            elif command == FREE_RESOURCES:
                compss.free_resources(*parameters)
            elif command == REGISTER_CORE_ELEMENT:
                compss.register_core_element(*parameters)
            elif command == PROCESS_TASK:
                compss.process_task(*parameters)
            elif command == PROCESS_HTTP_TASK:
                compss.process_http_task(*parameters)
            elif command == SET_PIPES:
                compss.set_pipes(*parameters)
            elif command == READ_PIPES:
                compss.read_pipes(*parameters)
            elif command == SET_WALL_CLOCK:
                compss.set_wall_clock(*parameters)
            else:
                raise PyCOMPSsException("Unknown link command")
Ejemplo n.º 3
0
def c_extension_link(in_queue, out_queue):
    # type: (..., ...) -> None
    """ Main C extension process.

    :param in_queue: Queue to receive messages.
    :param out_queue: Queue to send messages.
    :return: None
    """
    import compss

    alive = True
    while alive:
        message = in_queue.get()
        command = message[0]
        parameters = []
        if len(message) > 0:
            parameters = message[1:]
        if command == START:
            compss.start_runtime()
        elif command == SET_DEBUG:
            compss.set_debug(*parameters)
        elif command == STOP:
            compss.stop_runtime(*parameters)
            alive = False
        elif command == CANCEL_TASKS:
            compss.cancel_application_tasks(*parameters)
        elif command == ACCESSED_FILE:
            accessed = compss.accessed_file(*parameters)
            out_queue.put(accessed)
        elif command == OPEN_FILE:
            compss_name = compss.open_file(*parameters)
            out_queue.put(compss_name)
        elif command == CLOSE_FILE:
            compss.close_file(*parameters)
        elif command == DELETE_FILE:
            result = compss.delete_file(*parameters)
            out_queue.put(result)
        elif command == GET_FILE:
            compss.get_file(*parameters)
        elif command == GET_DIRECTORY:
            compss.get_directory(*parameters)
        elif command == BARRIER:
            compss.barrier(*parameters)
        elif command == BARRIER_GROUP:
            exception_message = compss.barrier_group(*parameters)
            out_queue.put(exception_message)
        elif command == OPEN_TASK_GROUP:
            compss.open_task_group(*parameters)
        elif command == CLOSE_TASK_GROUP:
            compss.close_task_group(*parameters)
        elif command == GET_LOGGING_PATH:
            log_path = compss.get_logging_path()
            out_queue.put(log_path)
        elif command == GET_NUMBER_OF_RESOURCES:
            num_resources = compss.get_number_of_resources(*parameters)
            out_queue.put(num_resources)
        elif command == REQUEST_RESOURCES:
            compss.request_resources(*parameters)
        elif command == FREE_RESOURCES:
            compss.free_resources(*parameters)
        elif command == REGISTER_CORE_ELEMENT:
            compss.register_core_element(*parameters)
        elif command == PROCESS_TASK:
            compss.process_task(*parameters)
        elif command == SET_PIPES:
            compss.set_pipes(*parameters)
        else:
            raise Exception("Unknown link command")