diff options
-rw-r--r-- | bot/__main__.py | 14 | ||||
-rw-r--r-- | bot/constants.py | 3 |
2 files changed, 15 insertions, 2 deletions
diff --git a/bot/__main__.py b/bot/__main__.py index 5c1184c10..0e2041bdb 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -1,11 +1,12 @@ import logging import os +import socket from aiohttp import AsyncResolver, ClientSession, TCPConnector from discord import Game from discord.ext.commands import AutoShardedBot, when_mentioned_or -from bot.constants import CLICKUP_KEY +from bot.constants import CLICKUP_KEY, DEBUG_MODE from bot.formatter import Formatter log = logging.getLogger(__name__) @@ -26,7 +27,16 @@ bot = AutoShardedBot( ) # Global aiohttp session for all cogs - uses asyncio for DNS resolution instead of threads, so we don't *spam threads* -bot.http_session = ClientSession(connector=TCPConnector(resolver=AsyncResolver())) +if DEBUG_MODE: + bot.http_session = ClientSession( + connector=TCPConnector( + resolver=AsyncResolver(), + family=socket.AF_INET, # Force aiohttp to use AF_INET if this is a local session. Prevents crashes. + verify_ssl=False, + ) + ) +else: + bot.http_session = ClientSession(connector=TCPConnector(resolver=AsyncResolver())) # Internal/debug bot.load_extension("bot.cogs.logging") diff --git a/bot/constants.py b/bot/constants.py index 4e8c9c900..651ffe0a8 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -1,5 +1,8 @@ import os +# Debug mode +DEBUG_MODE = True if 'local' in os.environ.get("SITE_URL", "local") else False + # Server PYTHON_GUILD = 267624335836053506 |