Skip to content

Commit 9ec80c9

Browse files
committed
fix: run command setup() outside handler lock to avoid blocking IRC
Move command setup() calls in the 376 handler into a fire-and-forget asyncio task so the handler lock is released immediately. This prevents NEMP's slow HTTP setup from blocking all other IRC message handlers.
1 parent 0be76d3 commit 9ec80c9

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

irc_handlers/rpl_endofmotd_376.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import logging
23

34
ID = "376"
@@ -27,6 +28,13 @@ async def execute(self, send_msg, prefix, command, params):
2728
if isinstance(self.auth, str):
2829
await send_msg(self.auth, 5)
2930

30-
for cmd in self.commands:
31-
if self.commands[cmd][0].setup:
32-
await self.commands[cmd][0].setup(self, True)
31+
asyncio.create_task(_run_command_setups(self))
32+
33+
34+
async def _run_command_setups(router):
35+
for cmd in router.commands:
36+
if router.commands[cmd][0].setup:
37+
try:
38+
await router.commands[cmd][0].setup(router, True)
39+
except Exception:
40+
logger.exception("setup() failed for command module '%s'", cmd)

0 commit comments

Comments
 (0)