mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[V3 Config] Fix unloading and implement singleton driver (#1458)
* Add the identifier as an initialization parameter * Remove config object singleton and opt for a shared JSON datastore * Fix bot unloading to deal with memory leaks * Fix tests * Fix clear all bug
This commit is contained in:
@@ -7,6 +7,7 @@ from importlib.machinery import ModuleSpec
|
||||
from pathlib import Path
|
||||
|
||||
import discord
|
||||
import sys
|
||||
from discord.ext.commands.bot import BotBase
|
||||
from discord.ext.commands import GroupMixin
|
||||
from discord.ext.commands import when_mentioned_or
|
||||
@@ -268,9 +269,15 @@ class RedBase(BotBase, RpcMethodMixin):
|
||||
pass
|
||||
finally:
|
||||
# finally remove the import..
|
||||
pkg_name = lib.__package__
|
||||
del lib
|
||||
del self.extensions[name]
|
||||
# del sys.modules[name]
|
||||
for m, _ in sys.modules.copy().items():
|
||||
if m.startswith(pkg_name):
|
||||
del sys.modules[m]
|
||||
|
||||
if pkg_name.startswith('redbot.cogs'):
|
||||
del sys.modules['redbot.cogs'].__dict__[name]
|
||||
|
||||
def register_rpc_methods(self):
|
||||
rpc.add_method('bot', self.rpc__cogs)
|
||||
|
||||
Reference in New Issue
Block a user