Implement uvloop

This commit is contained in:
Mark Veidemanis 2022-09-23 07:20:30 +01:00
parent 56b5c85fac
commit a8dbabd85e
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
4 changed files with 12 additions and 5 deletions

View File

@ -19,3 +19,5 @@ nltk
spacy
python-Levenshtein
orjson
uvloop
numba

View File

@ -1,4 +1,7 @@
import asyncio
import sys
import uvloop
from os import getenv
import util
@ -6,6 +9,9 @@ from sources.ch4 import Chan4
from sources.dis import DiscordClient
from sources.ingest import Ingest
# Use UVLoop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
log = util.get_logger("monolith")
modules_enabled = getenv("MODULES_ENABLED", False)
@ -16,22 +22,18 @@ if not token:
async def main(loop):
log.info("Starting Discord handler.")
client = DiscordClient()
loop.create_task(client.start(token))
log.info("Starting 4chan handler.")
chan = Chan4()
loop.create_task(chan.run())
log.info("Starting ingest handler.")
ingest = Ingest()
loop.create_task(ingest.run())
loop = asyncio.get_event_loop()
loop.create_task(main(loop))
# reactor.run()
try:
loop.run_forever()
except KeyboardInterrupt:

View File

@ -20,3 +20,5 @@ nltk
spacy
python-Levenshtein
orjson
uvloop
numba

View File

@ -14,6 +14,7 @@ class DiscordClient(discord.Client):
self.did_something = False
name = self.__class__.__name__
self.log = util.get_logger(name)
self.log.info("Starting Discord client")
super().__init__(*args, **kwargs)