Пример #1
0
def main():  # pylint: disable=missing-docstring
    args = parseArguments()

    _setupPipeRedirection(args.stdout, args.stderr)
    _setupPaths()

    # Call it again to log the paths we added
    import hdlcc
    from hdlcc import handlers
    import hdlcc.utils as utils  # pylint: disable=redefined-outer-name

    def _attachPids(source_pid, target_pid):
        "Monitors if source_pid is alive. If not, terminate target_pid"

        def _watchPidWrapper():
            "PID attachment monitor"
            try:
                if utils.isProcessRunning(source_pid):
                    Timer(1, _watchPidWrapper).start()
                else:
                    _logger.warning("Process %d is not running anymore",
                                    source_pid)
                    utils.terminateProcess(target_pid)
            except (TypeError, AttributeError):  # pragma: no cover
                return

        _logger.debug("Setting up PID attachment from %s to %s", source_pid,
                      target_pid)

        Timer(2, _watchPidWrapper).start()

    utils.setupLogging(args.log_stream, args.log_level, args.color)
    _logger.info(
        "Starting server. Our PID is %s, %s. Version string for hdlcc is '%s'",
        os.getpid(),
        "no parent PID to attach to" if args.attach_to_pid is None else \
        "our parent is %s" % args.attach_to_pid,
        hdlcc.__version__)

    if args.attach_to_pid is not None:
        _attachPids(args.attach_to_pid, os.getpid())

    handlers.app.run(host=args.host,
                     port=args.port,
                     threads=20,
                     server='waitress')
Пример #2
0
def main(): # pylint: disable=missing-docstring
    args = parseArguments()

    _setupPipeRedirection(args.stdout, args.stderr)
    _setupPaths()

    # Call it again to log the paths we added
    import hdlcc
    from hdlcc import handlers
    import hdlcc.utils as utils # pylint: disable=redefined-outer-name

    def _attachPids(source_pid, target_pid):
        "Monitors if source_pid is alive. If not, terminate target_pid"
        def _watchPidWrapper():
            "PID attachment monitor"
            try:
                if utils.isProcessRunning(source_pid):
                    Timer(1, _watchPidWrapper).start()
                else:
                    _logger.warning("Process %d is not running anymore", source_pid)
                    utils.terminateProcess(target_pid)
            except (TypeError, AttributeError):  # pragma: no cover
                return

        _logger.debug("Setting up PID attachment from %s to %s", source_pid,
                      target_pid)

        Timer(2, _watchPidWrapper).start()

    utils.setupLogging(args.log_stream, args.log_level, args.color)
    _logger.info(
        "Starting server. Our PID is %s, %s. Version string for hdlcc is '%s'",
        os.getpid(),
        "no parent PID to attach to" if args.attach_to_pid is None else \
        "our parent is %s" % args.attach_to_pid,
        hdlcc.__version__)

    if args.attach_to_pid is not None:
        _attachPids(args.attach_to_pid, os.getpid())

    handlers.app.run(host=args.host, port=args.port, threads=20,
                     server='waitress')
Пример #3
0
def main():
    "Main hook for standalone usage"
    start = time.time()
    runner_args = parseArguments()
    setupLogging(sys.stdout, runner_args.log_level)
    logging.root.setLevel(runner_args.log_level)
    #  logging.getLogger('hdlcc.source_file').setLevel(logging.WARNING)
    logging.getLogger('hdlcc.config_parser').setLevel(logging.WARNING)
    #  logging.getLogger('hdlcc.builders').setLevel(logging.INFO)
    logging.getLogger('vunit.project').setLevel(logging.ERROR)

    # Running hdlcc with threads has two major drawbacks:
    # 1) Makes interrupting it impossible currently because each source
    #    file is parsed on is own thread. Since there can be lots of
    #    sources, interrupting a single thread is not enough. This is
    #    discussed at https://github.com/suoto/hdlcc/issues/19
    # 2) When profiling, the result expected is of the inner hdlcc calls
    #    and with threads we have no info. This is discussed at
    #    https://github.com/suoto/hdlcc/issues/16
    # poor results (see suoto/hdlcc/issues/16).
    # To circumvent this we disable using threads at all when running
    # via standalone (it's ugly, I know)
    # pylint: disable=protected-access
    StandaloneProjectBuilder._USE_THREADS = False
    # pylint: enable=protected-access

    if runner_args.debug_profiling:
        profile.runctx(
            'runner(runner_args)',
            globals=globals(),
            locals={'runner_args' : runner_args},
            filename=runner_args.debug_profiling, sort=-1)
    else:
        runner(runner_args)
    end = time.time()
    _logger.info("Process took %.2fs", (end - start))
Пример #4
0
def main():
    "Main hook for standalone usage"
    start = time.time()
    runner_args = parseArguments()
    setupLogging(sys.stdout, runner_args.log_level)
    logging.root.setLevel(runner_args.log_level)
    #  logging.getLogger('hdlcc.source_file').setLevel(logging.WARNING)
    logging.getLogger('hdlcc.config_parser').setLevel(logging.WARNING)
    #  logging.getLogger('hdlcc.builders').setLevel(logging.INFO)
    logging.getLogger('vunit.project').setLevel(logging.ERROR)

    # Running hdlcc with threads has two major drawbacks:
    # 1) Makes interrupting it impossible currently because each source
    #    file is parsed on is own thread. Since there can be lots of
    #    sources, interrupting a single thread is not enough. This is
    #    discussed at https://github.com/suoto/hdlcc/issues/19
    # 2) When profiling, the result expected is of the inner hdlcc calls
    #    and with threads we have no info. This is discussed at
    #    https://github.com/suoto/hdlcc/issues/16
    # poor results (see suoto/hdlcc/issues/16).
    # To circumvent this we disable using threads at all when running
    # via standalone (it's ugly, I know)
    # pylint: disable=protected-access
    StandaloneProjectBuilder._USE_THREADS = False
    # pylint: enable=protected-access

    if runner_args.debug_profiling:
        profile.runctx('runner(runner_args)',
                       globals=globals(),
                       locals={'runner_args': runner_args},
                       filename=runner_args.debug_profiling,
                       sort=-1)
    else:
        runner(runner_args)
    end = time.time()
    _logger.info("Process took %.2fs", (end - start))