def wrapper(*args, **kwargs):
     config = None
     for arg in args:
         if ipython.is_std_config_arg(arg):
             config = arg
             break
         elif ipython.is_nested_config_arg(arg):
             config = arg["config"]
             break
     assert config, "Could not find config dictionary in function arguments."
     if config.get("parallel", {}).get("log_queue"):
         handler = setup_local_logging(config, config["parallel"])
     else:
         handler = None
     try:
         out = f(*args, **kwargs)
     finally:
         if handler and hasattr(handler, "close"):
             handler.close()
     return out
def _setup_logging(args):
    config = None
    if len(args) == 1 and isinstance(args[0], (list, tuple)):
        args = args[0]
    for arg in args:
        if ipython.is_nested_config_arg(arg):
            config = arg["config"]
            break
        elif ipython.is_std_config_arg(arg):
            config = arg
            break
    if config is not None:
        setup_logging(config)
    else:
        raise NotImplementedError("No config in %s:" % args[0])
    try:
        yield None
    except:
        logger.exception("Unexpected error")
        raise
def _setup_logging(args):
    config = None
    if len(args) == 1 and isinstance(args[0], (list, tuple)):
        args = args[0]
    for arg in args:
        if ipython.is_nested_config_arg(arg):
            config = arg["config"]
            break
        elif ipython.is_std_config_arg(arg):
            config = arg
            break
    if config is None:
        raise NotImplementedError("No config in %s:" % args[0])
    handler = setup_local_logging(config, config.get("parallel", {}))
    try:
        yield None
        if hasattr(handler, "close"):
            handler.close()
    except:
        logger.exception("Unexpected error")
        raise
Exemple #4
0
def _setup_logging(args):
    config = None
    if len(args) == 1 and isinstance(args[0], (list, tuple)):
        args = args[0]
    for arg in args:
        if ipython.is_nested_config_arg(arg):
            config = arg["config"]
            break
        elif ipython.is_std_config_arg(arg):
            config = arg
            break
    if config is None:
        raise NotImplementedError("No config in %s:" % args[0])
    handler = setup_local_logging(config, config.get("parallel", {}))
    try:
        yield None
        if hasattr(handler, "close"):
            handler.close()
    except:
        logger.exception("Unexpected error")
        raise