Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import asyncio
import logging
import sys
from pathlib import Path
import aiorun
import tomlkit
from . import DEFAULT_CONFIG_PATH, util
from .core import Bot
log = logging.getLogger("launch")
# Silence aiorun's overly verbose logger
aiorun.logger.disabled = True
def setup_asyncio(config: util.config.Config) -> asyncio.AbstractEventLoop:
"""Returns a new asyncio event loop with settings from the given config."""
asyncio_config: util.config.AsyncIOConfig = config["asyncio"]
if sys.platform == "win32":
# Force ProactorEventLoop on Windows for subprocess support
policy = asyncio.WindowsProactorEventLoopPolicy()
asyncio.set_event_loop_policy(policy)
elif not asyncio_config["disable_uvloop"]:
# Initialize uvloop if available
try:
# noinspection PyUnresolvedReferences
import uvloop