aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/bot.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/bot/bot.py b/bot/bot.py
index 9f48c980c..0287ec925 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -72,7 +72,18 @@ class Bot(commands.Bot):
# Use asyncio for DNS resolution instead of threads so threads aren't spammed.
# Use AF_INET as its socket family to prevent HTTPS related problems both locally
# and in production.
+
+ # Doesn't seem to have any state with regards to being closed, so no need to worry?
self._resolver = aiohttp.AsyncResolver()
+
+ # Does have a closed state. Its __del__ will warn about this, but let's do it immediately.
+ if self._connector and not self._connector._closed:
+ warnings.warn(
+ "The previous connector was not closed; it will remain open and be overwritten",
+ ResourceWarning,
+ stacklevel=2
+ )
+
self._connector = aiohttp.TCPConnector(
resolver=self._resolver,
family=socket.AF_INET,
@@ -82,5 +93,12 @@ class Bot(commands.Bot):
# this connector attribute.
self.http.connector = self._connector
+ if self.http_session and not self.http_session.closed:
+ warnings.warn(
+ "The previous ClientSession was not closed; it will remain open and be overwritten",
+ ResourceWarning,
+ stacklevel=2
+ )
+
self.http_session = aiohttp.ClientSession(connector=self._connector)
self.api_client.recreate(connector=self._connector)