From fa3e91aa6b2544f28d70ec4a69d7235b4149d340 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 9 Apr 2017 20:26:51 +0200 Subject: Fix ssl warning tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It wasn’t blocking because the asyncio api slightly changed in december which prevent us from running another event loop while a first one was already running. This bypasses asyncio completely, thus avoiding future problems (hopefully the select() API won’t change soon) --- poezio/core/handlers.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'poezio/core') diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py index 3ce71af6..d56f451c 100644 --- a/poezio/core/handlers.py +++ b/poezio/core/handlers.py @@ -8,6 +8,7 @@ log = logging.getLogger(__name__) import asyncio import curses import functools +import select import ssl import sys import time @@ -1235,8 +1236,6 @@ class HandlerCore: self.core.information('You refused to validate the certificate.' ' You are now disconnected.', 'Info') self.core.disconnect() - new_loop.stop() - asyncio.set_event_loop(old_loop) confirm_tab = tabs.ConfirmTab(self.core, 'Certificate check required', @@ -1248,14 +1247,11 @@ class HandlerCore: self.core.add_tab(confirm_tab, True) self.core.doupdate() - # some magic to avoid running the event loop in which slixmpp - # does stuff. FIXME: not perfect. - old_loop = asyncio.get_event_loop() - new_loop = asyncio.new_event_loop() - asyncio.set_event_loop(new_loop) - new_loop.add_reader(sys.stdin, self.core.on_input_readable) - curses.beep() - new_loop.run_forever() + while not confirm_tab.done: + sel = select.select([sys.stdin], [], [], 5)[0] + + if sel: + self.core.on_input_readable() def validate_ssl(self, pem): """ -- cgit v1.2.3