mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
make sure to run commands in the multiserver asyncio loop
This commit is contained in:
@@ -23,6 +23,7 @@ class DBCommandProcessor(ServerCommandProcessor):
|
|||||||
class WebHostContext(Context):
|
class WebHostContext(Context):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(WebHostContext, self).__init__("", 0, "", 1, 40, True, "enabled", "enabled", 0)
|
super(WebHostContext, self).__init__("", 0, "", 1, 40, True, "enabled", "enabled", 0)
|
||||||
|
self.main_loop = asyncio.get_running_loop()
|
||||||
|
|
||||||
def listen_to_db_commands(self):
|
def listen_to_db_commands(self):
|
||||||
cmdprocessor = DBCommandProcessor(self)
|
cmdprocessor = DBCommandProcessor(self)
|
||||||
@@ -32,7 +33,7 @@ class WebHostContext(Context):
|
|||||||
commands = select(command for command in Command if command.room.id == self.room_id)
|
commands = select(command for command in Command if command.room.id == self.room_id)
|
||||||
if commands:
|
if commands:
|
||||||
for command in commands:
|
for command in commands:
|
||||||
cmdprocessor(command.commandtext)
|
self.main_loop.call_soon_threadsafe(cmdprocessor, command.commandtext)
|
||||||
command.delete()
|
command.delete()
|
||||||
commit()
|
commit()
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
Reference in New Issue
Block a user