@contextlib.contextmanager
def logging_context(logging_configurer_fn, logging_level=logging.DEBUG):
    logging_queue = multiprocessing.Queue()
    logging_process_object = multiprocessing.Process(
        target=_logging_process,
        args=(logging_queue, logging_configurer_fn))
    logging_process_object.start()

    # configure the current process to log to the logger process
    handler = _QueueLoggingHandler(logging_queue)
    root_logger = logging.getLogger()
    root_logger.addHandler(handler)
    root_logger.setLevel(logging_level)

    try:
        yield
    finally:
        # instruct the logger process to stop by sending it 'None'
        root_logger.removeHandler(handler)
        logging_queue.put_nowait(None)
        logging_process_object.join()
A context manager that creates a separate process for logging.
dataset/ETHPy150Open bloomberg/phabricator-tools/py/phl/phlsys_multiprocessing.py/logging_context