Skip to content

Commit 77c6568

Browse files
committed
Wait until config cache is populated before dispatching closures
1 parent b5a7899 commit 77c6568

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# v2.5.2
8+
9+
Non-Breaking Internal Changes. (This shouldn't affect anyone.)
710

811
# v2.5.0
912

bot.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = '2.5.1'
25+
__version__ = '2.5.2'
2626

2727
import asyncio
2828
import textwrap
@@ -61,6 +61,7 @@ def __init__(self):
6161
self.threads = ThreadManager(self)
6262
self.session = aiohttp.ClientSession(loop=self.loop)
6363
self.config = ConfigManager(self)
64+
self.config_ready = asyncio.Event()
6465
self.selfhosted = bool(self.config.get('mongo_uri'))
6566
if self.selfhosted:
6667
self.db = AsyncIOMotorClient(self.config.mongo_uri).modmail_bot
@@ -177,6 +178,7 @@ async def on_connect(self):
177178
print(Fore.CYAN + 'Connected to gateway.')
178179

179180
await self.config.refresh()
181+
self.config_ready.set()
180182

181183
activity_type = self.config.get('activity_type')
182184
message = self.config.get('activity_message')
@@ -203,6 +205,8 @@ async def on_ready(self):
203205
print(Fore.RED + Style.BRIGHT + 'WARNING - The GUILD_ID provided does not exist!' + Style.RESET_ALL)
204206
else:
205207
await self.threads.populate_cache()
208+
209+
await self.config_ready.wait() # Wait until config cache is popluated with stuff from db
206210

207211
closures = self.config.closures.copy()
208212

0 commit comments

Comments
 (0)