main.py: fix v2 modules reloading
This commit is contained in:
parent
3e80a6effb
commit
7e0a47e498
7
main.py
7
main.py
|
@ -7,6 +7,7 @@ import sys
|
|||
import os
|
||||
import threading
|
||||
import importlib
|
||||
import imp
|
||||
|
||||
# global variables
|
||||
STOP_REQUESTED = False
|
||||
|
@ -172,6 +173,12 @@ def queue_processor():
|
|||
if len(command) >= 2 and command[0] == "module":
|
||||
if command[1] == "reload":
|
||||
print("[INFO] Module reloading triggered by a command")
|
||||
|
||||
# properly reload all v2 modules
|
||||
for mod in mcu.modules:
|
||||
if mod.version == 2:
|
||||
imp.reload(mod.obj)
|
||||
|
||||
del mcu.modules[:]
|
||||
mcu.reload_modules()
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import sys
|
|||
import os
|
||||
import threading
|
||||
import importlib
|
||||
import imp
|
||||
|
||||
from telegram import Message, Chat
|
||||
|
||||
|
@ -175,6 +176,12 @@ def queue_processor():
|
|||
if len(command) >= 2 and command[0] == "module":
|
||||
if command[1] == "reload":
|
||||
print("[INFO] Module reloading triggered by a command")
|
||||
|
||||
# properly reload all v2 modules
|
||||
for mod in mcu.modules:
|
||||
if mod.version == 2:
|
||||
imp.reload(mod.obj)
|
||||
|
||||
del mcu.modules[:]
|
||||
mcu.reload_modules()
|
||||
|
||||
|
|
Loading…
Reference in New Issue