diff --git a/run.py b/run.py index 3342e7d..5b81fb4 100644 --- a/run.py +++ b/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"]) \ No newline at end of file + client.run(PrivateConfig["bot-key"])