Merge remote-tracking branch 'origin/espy-uvloop' into development
This commit is contained in:
commit
566de1578f
15
run.py
15
run.py
@ -2,6 +2,7 @@
|
||||
# -*- coding: utf8 -*-
|
||||
|
||||
# Import packages
|
||||
import asyncio
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import json
|
||||
@ -11,6 +12,18 @@ import random
|
||||
# Import custom files
|
||||
from src.config.config import LoadConfig
|
||||
|
||||
# If uvloop is installed, change to that eventloop policy as it
|
||||
# is more efficient
|
||||
try:
|
||||
import uvloop
|
||||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||
del uvloop
|
||||
except BaseException as ex:
|
||||
print(f'Could not load uvloop. {type(ex).__name__}: {ex};',
|
||||
'reverting to default impl.')
|
||||
else:
|
||||
print(f'Using uvloop for asyncio event loop policy.')
|
||||
|
||||
|
||||
# Bot Class
|
||||
class SebiMachine(commands.Bot, LoadConfig):
|
||||
@ -67,4 +80,4 @@ if __name__ == '__main__':
|
||||
with open('src/config/PrivateConfig.json') as fp:
|
||||
PrivateConfig = json.load(fp)
|
||||
fp.close()
|
||||
client.run(PrivateConfig["bot-key"])
|
||||
client.run(PrivateConfig["bot-key"])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user