Implement uvloop
This commit is contained in:
parent
56b5c85fac
commit
a8dbabd85e
|
@ -19,3 +19,5 @@ nltk
|
|||
spacy
|
||||
python-Levenshtein
|
||||
orjson
|
||||
uvloop
|
||||
numba
|
||||
|
|
12
monolith.py
12
monolith.py
|
@ -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:
|
||||
|
|
|
@ -20,3 +20,5 @@ nltk
|
|||
spacy
|
||||
python-Levenshtein
|
||||
orjson
|
||||
uvloop
|
||||
numba
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue