Implement uvloop
This commit is contained in:
parent
56b5c85fac
commit
a8dbabd85e
|
@ -19,3 +19,5 @@ nltk
|
||||||
spacy
|
spacy
|
||||||
python-Levenshtein
|
python-Levenshtein
|
||||||
orjson
|
orjson
|
||||||
|
uvloop
|
||||||
|
numba
|
||||||
|
|
12
monolith.py
12
monolith.py
|
@ -1,4 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import sys
|
||||||
|
import uvloop
|
||||||
|
|
||||||
from os import getenv
|
from os import getenv
|
||||||
|
|
||||||
import util
|
import util
|
||||||
|
@ -6,6 +9,9 @@ from sources.ch4 import Chan4
|
||||||
from sources.dis import DiscordClient
|
from sources.dis import DiscordClient
|
||||||
from sources.ingest import Ingest
|
from sources.ingest import Ingest
|
||||||
|
|
||||||
|
# Use UVLoop
|
||||||
|
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||||
|
|
||||||
log = util.get_logger("monolith")
|
log = util.get_logger("monolith")
|
||||||
|
|
||||||
modules_enabled = getenv("MODULES_ENABLED", False)
|
modules_enabled = getenv("MODULES_ENABLED", False)
|
||||||
|
@ -16,22 +22,18 @@ if not token:
|
||||||
|
|
||||||
|
|
||||||
async def main(loop):
|
async def main(loop):
|
||||||
log.info("Starting Discord handler.")
|
|
||||||
client = DiscordClient()
|
client = DiscordClient()
|
||||||
loop.create_task(client.start(token))
|
loop.create_task(client.start(token))
|
||||||
|
|
||||||
log.info("Starting 4chan handler.")
|
|
||||||
chan = Chan4()
|
chan = Chan4()
|
||||||
loop.create_task(chan.run())
|
loop.create_task(chan.run())
|
||||||
|
|
||||||
log.info("Starting ingest handler.")
|
|
||||||
ingest = Ingest()
|
ingest = Ingest()
|
||||||
loop.create_task(ingest.run())
|
loop.create_task(ingest.run())
|
||||||
|
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.create_task(main(loop))
|
loop.create_task(main(loop))
|
||||||
# reactor.run()
|
|
||||||
try:
|
try:
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
|
@ -20,3 +20,5 @@ nltk
|
||||||
spacy
|
spacy
|
||||||
python-Levenshtein
|
python-Levenshtein
|
||||||
orjson
|
orjson
|
||||||
|
uvloop
|
||||||
|
numba
|
||||||
|
|
|
@ -14,6 +14,7 @@ class DiscordClient(discord.Client):
|
||||||
self.did_something = False
|
self.did_something = False
|
||||||
name = self.__class__.__name__
|
name = self.__class__.__name__
|
||||||
self.log = util.get_logger(name)
|
self.log = util.get_logger(name)
|
||||||
|
self.log.info("Starting Discord client")
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue