From ee0d1d269c54b33b085a5e3e700d084b89e93e7a Mon Sep 17 00:00:00 2001 From: Vicente Rivera Date: Sat, 9 Dec 2017 20:58:01 -0300 Subject: [PATCH] [V3 Streams] Fix race issue on init (#1135) * Fix for #1132 Fixes `self.streams` being a `Task` object instead of a list. Also replicated for `self.communities`, since the issue is the same (although untested, it can be inferred). * Implement sub-method to avoid init errors The new method waits for `streams` and `communities` to be initialized before running the `_stream_alerts` method, avoiding possible errors due to lists being uninitialized * Fix streams and communities loading * Delete IDE config file --- redbot/cogs/streams/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/redbot/cogs/streams/main.py b/redbot/cogs/streams/main.py index a6d6db7ed..e030f3943 100644 --- a/redbot/cogs/streams/main.py +++ b/redbot/cogs/streams/main.py @@ -41,8 +41,12 @@ class Streams: self.bot = bot - self.streams = self.bot.loop.create_task(self.load_streams()) - self.communities = self.bot.loop.create_task(self.load_communities()) + self.bot.loop.create_task(self._initialize_lists()) + + async def _initialize_lists(self): + self.streams = await self.load_streams() + self.communities = await self.load_communities() + self.task = self.bot.loop.create_task(self._stream_alerts()) @commands.command()