From e7fa46b5f507e574af27570446353f5f6de880e8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 8 Jun 2017 20:56:19 +0100 Subject: [PATCH] move websocket to asynio --- openlp/core/api/websockets.py | 11 +++++------ openlp/plugins/remotes/remoteplugin.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/openlp/core/api/websockets.py b/openlp/core/api/websockets.py index 1143838fb..cf4d83425 100644 --- a/openlp/core/api/websockets.py +++ b/openlp/core/api/websockets.py @@ -112,8 +112,7 @@ class WebSocketServer(RegistryProperties, OpenLPMixin): time.sleep(0.1) @staticmethod - @asyncio.coroutine - def handle_websocket(request, path): + async def handle_websocket(request, path): """ Handle web socket requests and return the poll information. Check ever 0.2 seconds to get the latest position and send if changed. @@ -131,13 +130,13 @@ class WebSocketServer(RegistryProperties, OpenLPMixin): while True: current_poll = poller.poll() if current_poll != previous_poll: - yield from request.send(json.dumps(current_poll).encode()) + await request.send(json.dumps(current_poll).encode()) previous_poll = current_poll - yield from asyncio.sleep(0.2) + await asyncio.sleep(0.2) elif path == '/live_changed': while True: main_poll = poller.main_poll() if main_poll != previous_main_poll: - yield from request.send(main_poll) + await request.send(main_poll) previous_main_poll = main_poll - yield from asyncio.sleep(0.2) + await asyncio.sleep(0.2) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index a7eb81401..d3fe253c7 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -44,7 +44,7 @@ class RemotesPlugin(Plugin, OpenLPMixin): self.icon = build_icon(self.icon_path) self.weight = -1 register_endpoint(remote_endpoint) - Registry().register_function('download_website', self.manage_download) + Registry().register_function('download_website', self.first_time) def initialise(self): """