예제 #1
0
파일: McPy.py 프로젝트: mcpyproject/McPy
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)
예제 #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
예제 #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()
예제 #4
0
파일: main.py 프로젝트: vnguye34/McPy
    # TODO Use --debug flag
    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)
예제 #5
0
from cogs.help import BoatHelp
import sentry_sdk
try:
    from blackfire import probe
except (ImportError, ModuleNotFoundError):
    blackfire = False
else:
    blackfire = True

asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

config = load_config()

if blackfire:
    bf_config = config["auth"]["blackfire"]
    probe.initialize(**bf_config)
    probe.enable()

sentry_sdk.init(config["auth"]["sentry"]["sentry_url"], traces_sample_rate=1.0)

if config['database']['enable']:
    asyncio.ensure_future(init_db_connection(config['database']))

basic_intents = discord.Intents.none()
basic_intents.guilds = True
basic_intents.webhooks = True
basic_intents.messages = True
basic_intents.reactions = True
bot = MyBot(
    description=config["bot"]["description"],
    intents=basic_intents,