diff options
author | mathieui <mathieui@mathieui.net> | 2017-04-09 20:26:51 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2017-04-09 20:26:51 +0200 |
commit | fa3e91aa6b2544f28d70ec4a69d7235b4149d340 (patch) | |
tree | 1834d05908be96f224e1c47bdc361f0f1b04f9e5 | |
parent | f154dcbc824dc343554b0d340a624f1af6705238 (diff) | |
download | poezio-fa3e91aa6b2544f28d70ec4a69d7235b4149d340.tar.gz poezio-fa3e91aa6b2544f28d70ec4a69d7235b4149d340.tar.bz2 poezio-fa3e91aa6b2544f28d70ec4a69d7235b4149d340.tar.xz poezio-fa3e91aa6b2544f28d70ec4a69d7235b4149d340.zip |
Fix ssl warning tab
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)
-rw-r--r-- | poezio/core/handlers.py | 16 | ||||
-rw-r--r-- | poezio/tabs/confirmtab.py | 2 |
2 files changed, 8 insertions, 10 deletions
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): """ diff --git a/poezio/tabs/confirmtab.py b/poezio/tabs/confirmtab.py index 49339fce..39f630cb 100644 --- a/poezio/tabs/confirmtab.py +++ b/poezio/tabs/confirmtab.py @@ -40,6 +40,7 @@ class ConfirmTab(Tab): self.update_keys() self.update_commands() self.completion_callback = callback + self.done = False def toggle_choice(self): self.dialog.toggle_choice() @@ -81,6 +82,7 @@ class ConfirmTab(Tab): self.input.resize(1, self.width, self.height-1, 0) def close(self, arg=None): + self.done = True self.core.close_tab(self) def on_input(self, key, raw): |