Skip to content

Commit

Permalink
Remove deep reload references
Browse files Browse the repository at this point in the history
It's just simply impossible to do so in a stable way
  • Loading branch information
No767 committed Jan 26, 2024
1 parent 6cec144 commit 8fc07c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions bot/libs/utils/reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
from rodhaj import Rodhaj


class DeepReloader:
class Reloader:
"""An watchdog for reloading extensions and library files
This reloads/loads extensions and reloads/loads library files.
This will do an deep reload, meaning that it will reload
all occurrences of the imported module. Hence the name, DeepReloader
This reloads/unloads extensions, and also reloads library modules.
This does not implement a deep reload, as there is no way to do so
that way.
"""

def __init__(self, bot: Rodhaj, path: Path):
Expand Down Expand Up @@ -52,7 +52,7 @@ async def reload_or_load_extension(self, module: str) -> None:
await self.bot.load_extension(module)
self.logger.info("Loaded extension: %s", module)

async def deep_reload_library(self, module: str) -> None:
async def reload_library(self, module: str) -> None:
try:
actual_module = sys.modules[module]
importlib.reload(actual_module)
Expand All @@ -62,7 +62,7 @@ async def deep_reload_library(self, module: str) -> None:

async def reload_extension_or_library(self, module: str) -> None:
if module.startswith("libs"):
await self.deep_reload_library(module)
await self.reload_library(module)
elif module.startswith("cogs"):
await self.reload_or_load_extension(module)

Expand Down
6 changes: 3 additions & 3 deletions bot/rodhaj.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
RodhajHelp,
send_error_embed,
)
from libs.utils.reloader import DeepReloader
from libs.utils.reloader import Reloader

if TYPE_CHECKING:
from cogs.tickets import Tickets
Expand Down Expand Up @@ -60,7 +60,7 @@ def __init__(
self.transprogrammer_guild_id = TRANSPROGRAMMER_GUILD_ID
self.version = str(VERSION)
self._dev_mode = dev_mode
self._reloader = DeepReloader(self, Path(__file__).parent)
self._reloader = Reloader(self, Path(__file__).parent)

### Ticket related utils
async def fetch_partial_config(self) -> Optional[PartialConfig]:
Expand Down Expand Up @@ -205,7 +205,7 @@ async def setup_hook(self) -> None:
self.partial_config = await self.fetch_partial_config()

if self._dev_mode:
self.logger.info("Dev mode is enabled. Loading DeepReloader")
self.logger.info("Dev mode is enabled. Loading Reloader")
self._reloader.start()

async def on_ready(self):
Expand Down

0 comments on commit 8fc07c3

Please sign in to comment.