synapse/app/_base.py
def start_reactor(
        appname,
        soft_file_limit,
        gc_thresholds,
        pid_file,
        daemonize,
        cpu_affinity,
        logger,
):
    """ Run the reactor in the main process

    Daemonizes if necessary, and then configures some resources, before starting
    the reactor

    Args:
        appname (str): application name which will be sent to syslog
        soft_file_limit (int):
        gc_thresholds:
        pid_file (str): name of pid file to write to if daemonize is True
        daemonize (bool): true to run the reactor in a background process
        cpu_affinity (int|None): cpu affinity mask
        logger (logging.Logger): logger instance to pass to Daemonize
    """

    def run():
        # make sure that we run the reactor with the sentinel log context,
        # otherwise other PreserveLoggingContext instances will get confused
        # and complain when they see the logcontext arbitrarily swapping
        # between the sentinel and `run` logcontexts.
        with PreserveLoggingContext():
            logger.info("Running")
            if cpu_affinity is not None:
                if not affinity:
                    quit_with_error(
                        "Missing package 'affinity' required for cpu_affinity\n"
                        "option\n\n"
                        "Install by running:\n\n"
                        "   pip install affinity\n\n"
                    )
                logger.info("Setting CPU affinity to %s" % cpu_affinity)
                affinity.set_process_affinity_mask(0, cpu_affinity)
            change_resource_limit(soft_file_limit)
            if gc_thresholds:
                gc.set_threshold(*gc_thresholds)
            reactor.run()

    if daemonize:
        daemon = Daemonize(
            app=appname,
            pid=pid_file,
            action=run,
            auto_close_fds=False,
            verbose=True,
            logger=logger,
        )
        daemon.start()
    else:
        run()
 Run the reactor in the main process

    Daemonizes if necessary, and then configures some resources, before starting
    the reactor

    Args:
        appname (str): application name which will be sent to syslog
        soft_file_limit (int):
        gc_thresholds:
        pid_file (str): name of pid file to write to if daemonize is True
        daemonize (bool): true to run the reactor in a background process
        cpu_affinity (int|None): cpu affinity mask
        logger (logging.Logger): logger instance to pass to Daemonize
    
Run the reactor in the main process
Daemonizes if necessary, and then configures some resources, before starting
the reactor
Run the reactor in the main process Daemonizes if necessary and then configures some resources before starting the reactor
def start_reactor(
        appname,
        soft_file_limit,
        gc_thresholds,
        pid_file,
        daemonize,
        cpu_affinity,
        logger,
):
    def run():
        with PreserveLoggingContext():
            logger.info("Running")
            if cpu_affinity is not None:
                if not affinity:
                    quit_with_error(
                        "Missing package 'affinity' required for cpu_affinity\n"
                        "option\n\n"
                        "Install by running:\n\n"
                        "   pip install affinity\n\n"
                    )
                logger.info("Setting CPU affinity to %s" % cpu_affinity)
                affinity.set_process_affinity_mask(0, cpu_affinity)
            change_resource_limit(soft_file_limit)
            if gc_thresholds:
                gc.set_threshold(*gc_thresholds)
            reactor.run()
    if daemonize:
        daemon = Daemonize(
            app=appname,
            pid=pid_file,
            action=run,
            auto_close_fds=False,
            verbose=True,
            logger=logger,
        )
        daemon.start()
    else:
        run()
def start_reactor ( appname , soft_file_limit , gc_thresholds , pid_file , daemonize , cpu_affinity , logger , ) : def run ( ) : with PreserveLoggingContext ( ) : logger . info ( "Running" ) if cpu_affinity is not None : if not affinity : quit_with_error ( "Missing package 'affinity' required for cpu_affinity\n" "option\n\n" "Install by running:\n\n" "   pip install affinity\n\n" ) logger . info ( "Setting CPU affinity to %s" % cpu_affinity ) affinity . set_process_affinity_mask ( 0 , cpu_affinity ) change_resource_limit ( soft_file_limit ) if gc_thresholds : gc . set_threshold ( * gc_thresholds ) reactor . run ( ) if daemonize : daemon = Daemonize ( app = appname , pid = pid_file , action = run , auto_close_fds = False , verbose = True , logger = logger , ) daemon . start ( ) else : run ( )
Run the reactor in the main process
Daemonizes if necessary, and then configures some resources, before starting
the reactor
Run the reactor in the main process Daemonizes if necessary and then configures some resources before starting the reactor
""" Run the reactor in the main process

    Daemonizes if necessary, and then configures some resources, before starting
    the reactor

    Args:
        appname (str): application name which will be sent to syslog
        soft_file_limit (int):
        gc_thresholds:
        pid_file (str): name of pid file to write to if daemonize is True
        daemonize (bool): true to run the reactor in a background process
        cpu_affinity (int|None): cpu affinity mask
        logger (logging.Logger): logger instance to pass to Daemonize
    """ # make sure that we run the reactor with the sentinel log context, # otherwise other PreserveLoggingContext instances will get confused # and complain when they see the logcontext arbitrarily swapping # between the sentinel and `run` logcontexts.
appname
application name which will be sent to syslog
application name which will be sent to syslog
soft_file_limit
None
gc_thresholds
None
pid_file
name of pid file to write to if daemonize is True
name of pid file to write to if daemonize is True
daemonize
true to run the reactor in a background process
true to run the reactor in a background process
cpu_affinity
cpu affinity mask
cpu affinity mask
logger
logger instance to pass to Daemonize
logger instance to pass to Daemonize