diff --git a/README.md b/README.md index 1ae2ec34..f6d9a29b 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/TODO.md b/TODO.md index 52eea6b1..dc326b9a 100644 --- a/TODO.md +++ b/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 diff --git a/src/python/app.py b/src/python/app.py index e0726776..052e076b 100644 --- a/src/python/app.py +++ b/src/python/app.py @@ -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()