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)
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
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()
# 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)
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,