From abf3603bc9d73d8f1078661b28b17899d163c578 Mon Sep 17 00:00:00 2001 From: Vidir Valberg Gudmundsson Date: Mon, 17 Feb 2020 21:29:42 +0100 Subject: [PATCH] Maybe this fixes the IRC bot? --- src/ircbot/irc3module.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ircbot/irc3module.py b/src/ircbot/irc3module.py index adae9419..22b7d9f0 100644 --- a/src/ircbot/irc3module.py +++ b/src/ircbot/irc3module.py @@ -3,6 +3,7 @@ import re import time import irc3 +from asgiref.sync import sync_to_async from django.conf import settings from django.utils import timezone @@ -116,9 +117,10 @@ class Plugin(object): # logger.debug("inside do_stuff()") # call the methods we need to - self.bot.check_irc_channels() - self.bot.fix_missing_acls() - self.bot.get_outgoing_messages() + # call them with sync_to_async to be able to access database + sync_to_async(self.bot.check_irc_channels)() + sync_to_async(self.bot.fix_missing_acls)() + sync_to_async(self.bot.get_outgoing_messages)() # schedule a call of this function again in N seconds self.bot.loop.call_later(