Skip to content

Commit

Permalink
resolve _re_init_handler blocks the event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
rking32 committed Nov 5, 2021
1 parent 21bafa8 commit a7f379d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions userge/plugins/admin/antispam.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ async def _init() -> None:
s_o = await SAVED_SETTINGS.find_one(_ID)
if s_o:
Config.ANTISPAM_SENTRY = s_o['data']
_re_init_handler()
await _re_init_handler()


@pool.run_in_thread
def _re_init_handler():
global HANDLER # pylint: disable=global-statement
handler = GBanHandler()
Expand All @@ -60,7 +61,7 @@ async def antispam_(message: Message):
Config.ANTISPAM_SENTRY = not Config.ANTISPAM_SENTRY
text = f"`antispam {'enabled' if Config.ANTISPAM_SENTRY else 'disabled'} !`"
await message.edit(text, del_in=3)
_re_init_handler()
await _re_init_handler()
await SAVED_SETTINGS.update_one(_ID, {"$set": {'data': Config.ANTISPAM_SENTRY}}, upsert=True)


Expand Down

0 comments on commit a7f379d

Please sign in to comment.