[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:
Will
2018-04-02 20:47:27 -04:00
committed by palmtree5
parent 720ef38886
commit 29ce2401ca
7 changed files with 94 additions and 37 deletions

View File

@@ -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)