Merge remote-tracking branch 'origin/asynciofix' into development
This commit is contained in:
commit
523a2b094c
@ -11,6 +11,7 @@ import logging
|
|||||||
import random
|
import random
|
||||||
import traceback
|
import traceback
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
@ -27,9 +28,15 @@ logging.basicConfig(level='INFO')
|
|||||||
# If uvloop is installed, change to that eventloop policy as it
|
# If uvloop is installed, change to that eventloop policy as it
|
||||||
# is more efficient
|
# is more efficient
|
||||||
try:
|
try:
|
||||||
import uvloop
|
# https://stackoverflow.com/a/45700730
|
||||||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
if sys.platform == 'win32':
|
||||||
del uvloop
|
loop = asyncio.ProactorEventLoop()
|
||||||
|
asyncio.set_event_loop(loop)
|
||||||
|
logging.warning('Detected Windows. Changing event loop to ProactorEventLoop.')
|
||||||
|
else:
|
||||||
|
import uvloop
|
||||||
|
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||||
|
del uvloop
|
||||||
except BaseException as ex:
|
except BaseException as ex:
|
||||||
logging.warning(f'Could not load uvloop. {type(ex).__qualname__}: {ex};',
|
logging.warning(f'Could not load uvloop. {type(ex).__qualname__}: {ex};',
|
||||||
'reverting to default impl.')
|
'reverting to default impl.')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user