Esempio n. 1
0
def _launch(parser: Parser):
    try:
        # noinspection PyUnresolvedReferences
        from blackfire import probe  # Profiler: https://blackfire.io free with the Git Student Package
    except ImportError:
        BLACKFIRE_ENABLED = False
        logging.info("Blackfire not installed: passing")
    else:
        BLACKFIRE_ENABLED = True
        probe.initialize()
        probe.enable()
        logging.info("Blackfire Enabled!")

    avail_cores = get_available_core()

    # Here starts the server :D
    server = Server.Server(parser, avail_cores)
    if parser.test:
        server.run_test()
        return
    server.start()

    # End Network stuff
    server.stop()
    if BLACKFIRE_ENABLED:
        probe.end()
    logging.info("Server stopped: goodbye!")
    sys.exit(0)
Esempio n. 2
0
        def wrapper(*args, **kwargs):
            initialize(
                client_id=client_id,
                client_token=client_token,
                method="decorator",
                title=title,
            )
            enable()
            try:
                result = func(*args, **kwargs)
            finally:
                end()

            return result
Esempio n. 3
0
def bootstrap():
    try:
        patch_all()
    except:
        traceback.print_exc()

    try:
        query = os.environ.get('BLACKFIRE_QUERY')
        if query:
            del os.environ['BLACKFIRE_QUERY']

            from blackfire import probe

            probe.initialize(query=query, method="bootstrap")
            probe.enable(end_at_exit=True)
    except:
        traceback.print_exc()
Esempio n. 4
0
    logging.basicConfig(
        format="[%(asctime)s - %(levelname)s - %(threadName)s] %(message)s",
        level=logging.DEBUG)
    logging.root.setLevel(logging.NOTSET)

    try:
        logging.info("Trying to initialize the Blackfire probe")
        # noinspection PyUnresolvedReferences
        from blackfire import probe  # Profiler: https://blackfire.io free with the Git Student Package
    except ImportError:
        BLACKFIRE_ENABLED = False
        logging.info("Blackfire not installed: passing")
    else:
        BLACKFIRE_ENABLED = True
        probe.initialize()
        probe.enable()
        logging.info("Enabled!")

    logging.info("Starting queues...")
    TASK_LIST = {}
    try:
        TASK_QUEUE = multiprocessing.Queue(
            100
        )  # Allow the task queue to have up to 100 items in it at any given time
    except ImportError:
        logging.fatal(
            "No available shared semaphore implementation on the host system! See "
            "https://bugs.python.org/issue3770 for more info."
        )  # click the bug link
        sys.exit(-1)
    DONE_QUEUE = multiprocessing.Queue(