summaryrefslogtreecommitdiff
path: root/poezio
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2017-04-09 20:26:51 +0200
committermathieui <mathieui@mathieui.net>2017-04-09 20:26:51 +0200
commitfa3e91aa6b2544f28d70ec4a69d7235b4149d340 (patch)
tree1834d05908be96f224e1c47bdc361f0f1b04f9e5 /poezio
parentf154dcbc824dc343554b0d340a624f1af6705238 (diff)
downloadpoezio-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)
Diffstat (limited to 'poezio')
-rw-r--r--poezio/core/handlers.py16
-rw-r--r--poezio/tabs/confirmtab.py2
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):