Merge pull request #36 from DataBeaver/master

Fix asyncio event loop init in qml_bridge.py
This commit is contained in:
miruka 2020-05-15 09:05:27 -04:00 committed by GitHub
commit 80f6672fc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,12 +40,16 @@ class QMLBridge:
"""
def __init__(self) -> None:
try:
self._loop = asyncio.get_event_loop()
except RuntimeError:
self._loop = asyncio.new_event_loop()
asyncio.set_event_loop(self._loop)
self._loop.set_exception_handler(self._loop_exception_handler)
from .backend import Backend
self.backend: Backend = Backend()
self._loop = asyncio.get_event_loop()
self._loop.set_exception_handler(self._loop_exception_handler)
Thread(target=self._start_asyncio_loop).start()