Make uvloop dependency optional
This commit is contained in:
parent
446dc776b0
commit
ca2ecc75bb
|
@ -42,7 +42,11 @@ Install the Python 3 dependencies from Pypi:
|
|||
|
||||
pip3 install --user --upgrade \
|
||||
Pillow aiofiles appdirs dataclasses filetype hsluv html_sanitizer \
|
||||
lxml mistune uvloop
|
||||
lxml mistune
|
||||
|
||||
Optional dependency for performance improvements:
|
||||
|
||||
pip3 install --user --upgrade uvloop
|
||||
|
||||
Install the Python 3 dependencies from Github:
|
||||
|
||||
|
|
1
TODO.md
1
TODO.md
|
@ -11,7 +11,6 @@
|
|||
- When qml syntax highlighting supports ES6 string interpolation, use them
|
||||
|
||||
- Fixes
|
||||
- Make uvloop optional
|
||||
- Backspace bug
|
||||
|
||||
- Show error if uploading avatar fails or file is corrupted
|
||||
|
|
|
@ -6,7 +6,6 @@ from operator import attrgetter
|
|||
from threading import Thread
|
||||
from typing import Coroutine, Sequence
|
||||
|
||||
import uvloop
|
||||
from appdirs import AppDirs
|
||||
|
||||
from . import __about__, pyotherside
|
||||
|
@ -14,6 +13,15 @@ from .pyotherside_events import CoroutineDone
|
|||
|
||||
log.getLogger().setLevel(log.INFO)
|
||||
|
||||
try:
|
||||
import uvloop
|
||||
except ModuleNotFoundError:
|
||||
UVLOOP = False
|
||||
log.info("uvloop not available, using default asyncio loop.")
|
||||
else:
|
||||
UVLOOP = True
|
||||
log.info("uvloop is available.")
|
||||
|
||||
|
||||
class App:
|
||||
def __init__(self) -> None:
|
||||
|
@ -51,7 +59,10 @@ class App:
|
|||
|
||||
def _loop_starter(self) -> None:
|
||||
asyncio.set_event_loop(self.loop)
|
||||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||
|
||||
if UVLOOP:
|
||||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||
|
||||
self.loop.run_forever()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user