当前位置: 首页>>代码示例>>Python>>正文


Python logging.shutdown方法代码示例

本文整理汇总了Python中logging.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python logging.shutdown方法的具体用法?Python logging.shutdown怎么用?Python logging.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在logging的用法示例。


在下文中一共展示了logging.shutdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_simnibs

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def run_simnibs(simnibs_struct, cpus=1):
    """Runs a simnnibs problem.

    Parameters:
    --------------
    simnibs_struct: sim_struct.mat.SESSION of str
        SESSION of name of '.mat' file defining the simulation
    cpus: int
        Number of processes to run in parallel (if avaliable)
    """
    np.set_printoptions(precision=4)

    if isinstance(simnibs_struct, str):
        p = read_mat(simnibs_struct)
    else:
        p = simnibs_struct

    out = p.run(cpus=cpus)
    logging.shutdown()
    return out 
开发者ID:simnibs,项目名称:simnibs,代码行数:22,代码来源:run_simnibs.py

示例2: pytest_sessionfinish

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def pytest_sessionfinish(self):
        with self.live_logs_context():
            if self.log_cli_handler:
                self.log_cli_handler.set_when("sessionfinish")
            if self.log_file_handler is not None:
                try:
                    with catching_logs(
                        self.log_file_handler, level=self.log_file_level
                    ):
                        yield
                finally:
                    # Close the FileHandler explicitly.
                    # (logging.shutdown might have lost the weakref?!)
                    self.log_file_handler.close()
            else:
                yield 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:18,代码来源:logging.py

示例3: reset_logging

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def reset_logging():
    """Reset Logging"""
    manager = logging.root.manager
    manager.disabled = logging.NOTSET
    airflow_loggers = [
        logger for logger_name, logger in manager.loggerDict.items() if logger_name.startswith('airflow')
    ]
    for logger in airflow_loggers:  # pylint: disable=too-many-nested-blocks
        if isinstance(logger, logging.Logger):
            logger.setLevel(logging.NOTSET)
            logger.propagate = True
            logger.disabled = False
            logger.filters.clear()
            handlers = logger.handlers.copy()
            for handler in handlers:
                # Copied from `logging.shutdown`.
                try:
                    handler.acquire()
                    handler.flush()
                    handler.close()
                except (OSError, ValueError):
                    pass
                finally:
                    handler.release()
                logger.removeHandler(handler) 
开发者ID:apache,项目名称:airflow,代码行数:27,代码来源:test_logging_config.py

示例4: close

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def close(self):
        # typically, this method is called at interpreter exit
        # (by logging.shutdown() which is always registered with
        # atexit.register() machinery)
        try:
            try:
                super(AMQPHandler, self).close()
                self._closing = True
                self._pusher.shutdown()
            except:
                dump_condensed_debug_msg(
                    'EXCEPTION DURING EXECUTION OF close() OF THE AMQP LOGGING HANDLER!')
                raise
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            exc = sys.exc_info()[1]
            self._error_fifo.put(exc) 
开发者ID:CERT-Polska,项目名称:n6,代码行数:20,代码来源:log_helpers.py

示例5: signal_handler

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def signal_handler(signal, frame=None):
    state_machine_execution_engine = core_singletons.state_machine_execution_engine
    core_singletons.shut_down_signal = signal

    # in this case the print is on purpose to see more easily if the interrupt signal reached the thread
    print(_("Signal '{}' received.\nExecution engine will be stopped and program will be shutdown!").format(
        SIGNALS_TO_NAMES_DICT.get(signal, "[unknown]")))

    # close gui properly
    gui_singletons.main_window_controller.get_controller('menu_bar_controller').on_quit_activate(None)

    post_gui_destruction()

    logging.shutdown()

    # Do not use sys.exit() in signal handler:
    # http://thushw.blogspot.de/2010/12/python-dont-use-sysexit-inside-signal.html
    # noinspection PyProtectedMember
    os._exit(0) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:21,代码来源:start.py

示例6: register_signal_handlers

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def register_signal_handlers(callback):
    # When using plain signal.signal to install a signal handler, the GUI will not shutdown until it receives the
    # focus again. The following logic (inspired from https://stackoverflow.com/a/26457317) fixes this
    def install_glib_handler(sig):
        unix_signal_add = None

        if hasattr(GLib, "unix_signal_add"):
            unix_signal_add = GLib.unix_signal_add
        elif hasattr(GLib, "unix_signal_add_full"):
            unix_signal_add = GLib.unix_signal_add_full

        if unix_signal_add:
            unix_signal_add(GLib.PRIORITY_HIGH, sig, callback, sig)

    def idle_handler(*args):
        GLib.idle_add(callback, *args, priority=GLib.PRIORITY_HIGH)

    for signal_code in [signal.SIGHUP, signal.SIGINT, signal.SIGTERM]:
        signal.signal(signal_code, idle_handler)
        GLib.idle_add(install_glib_handler, signal_code, priority=GLib.PRIORITY_HIGH) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:22,代码来源:start.py

示例7: signal_handler

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def signal_handler(signal, frame):
    global _user_abort

    state_machine_execution_engine = core_singletons.state_machine_execution_engine
    core_singletons.shut_down_signal = signal

    logger.info("Shutting down ...")

    try:
        if not state_machine_execution_engine.finished_or_stopped():
            state_machine_execution_engine.stop()
            state_machine_execution_engine.join(3)  # Wait max 3 sec for the execution to stop
    except Exception:
        logger.exception("Could not stop state machine")

    _user_abort = True

    # shutdown twisted correctly
    if reactor_required():
        from twisted.internet import reactor
        if reactor.running:
            plugins.run_hook("pre_destruction")
            reactor.callFromThread(reactor.stop)

    logging.shutdown() 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:27,代码来源:start.py

示例8: setUp

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def setUp(self):
        super(LoggerAdapterTest, self).setUp()
        old_handler_list = logging._handlerList[:]

        self.recording = RecordingHandler()
        self.logger = logging.root
        self.logger.addHandler(self.recording)
        self.addCleanup(self.logger.removeHandler, self.recording)
        self.addCleanup(self.recording.close)

        def cleanup():
            logging._handlerList[:] = old_handler_list

        self.addCleanup(cleanup)
        self.addCleanup(logging.shutdown)
        self.adapter = logging.LoggerAdapter(logger=self.logger, extra=None) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:test_logging.py

示例9: main

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def main(args):
    """ Main

    """
    setup_logs()
    _logger.debug("Starting main()")

    args = parse_args(args)
    print("[*] Initiating attack on IP address {}:{}".format(args.ip, args.port))
    if args.test:
        pwn(args.ip, args.port, 'test')
    elif args.unique:
        pwn(args.ip, args.port, 'unique')
    elif args.chars:
        pwn(args.ip, args.port, 'chars')
    elif args.breakpoint:
        pwn(args.ip, args.port, 'break')
    else:
        pwn(args.ip, args.port, args.payload)

    _logger.debug("All done, shutting down.")
    logging.shutdown() 
开发者ID:sevro,项目名称:security-utilities,代码行数:24,代码来源:main.py

示例10: main

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def main(args):
    """ Main

    TODO: validate ip address input
    
    """
    setup_logs()
    _logger.debug("Starting main()")

    ips = []
    args = parse_args(args)
    print("[*] Fuzzing port {} on IP address {}".format(args.port, args.ip))
    fuzz(args.ip, args.port, args.size, args.increment)

    _logger.debug("All done, shutting down.")
    logging.shutdown() 
开发者ID:sevro,项目名称:security-utilities,代码行数:18,代码来源:main.py

示例11: kill_on_exception

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def kill_on_exception(logname):
    """decorator to ensure functions will kill ryu when an unhandled exception
    occurs"""
    def _koe(func):
        @wraps(func)
        def __koe(*args, **kwargs):
            try:
                func(*args, **kwargs)
            except:
                logging.getLogger(logname).exception(
                    "Unhandled exception, killing RYU")
                logging.shutdown()
                os.kill(os.getpid(), signal.SIGKILL)
        return __koe
    return _koe 
开发者ID:sdn-ixp,项目名称:iSDX,代码行数:17,代码来源:faucet_util.py

示例12: reset_logging

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def reset_logging():
    logging.shutdown()
    reload(logging) 
开发者ID:huge-success,项目名称:sanic,代码行数:5,代码来源:test_logging.py

示例13: tearDown

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def tearDown(self):
        if task_id() is not None:
            # We're in a child process, and probably got to this point
            # via an uncaught exception.  If we return now, both
            # processes will continue with the rest of the test suite.
            # Exit now so the parent process will restart the child
            # (since we don't have a clean way to signal failure to
            # the parent that won't restart)
            logging.error("aborting child process from tearDown")
            logging.shutdown()
            os._exit(1)
        # In the surviving process, clear the alarm we set earlier
        signal.alarm(0)
        super(ProcessTest, self).tearDown() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:16,代码来源:process_test.py

示例14: tearDownClass

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def tearDownClass(cls):
        logging.shutdown() 
开发者ID:microsoft,项目名称:knack,代码行数:4,代码来源:test_command_with_configured_defaults.py

示例15: init_logger

# 需要导入模块: import logging [as 别名]
# 或者: from logging import shutdown [as 别名]
def init_logger():
    """Reload the global logger."""
    global g_logger

    if g_logger is None:
        g_logger = logging.getLogger()
    else:
        logging.shutdown()
        g_logger.handlers = []

    g_logger.setLevel(logging.DEBUG) 
开发者ID:lucasxlu,项目名称:LagouJob,代码行数:13,代码来源:log.py


注:本文中的logging.shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。