diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-07-17 10:53:15 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-07-26 10:32:39 -0700 |
commit | f1e225cbb571920bb6d17f6ff15013f2c69c6c6c (patch) | |
tree | b8ef381eb82a6ad7cf75143610a47808e3d9ddea /alot/ui.py | |
parent | b19d58f556932eec92e3cf27f6c018791415367d (diff) |
Use twisted reactor as asyncio event loop
This puts the twisted event loop into the asyncio framework. This means
that we're currently running all over our twisted.defered's and
twisted.inlineCallbacks through asyncio, using the twisted loop. This
will allow incremental updates from twisted's event loop to a standard
asyncio event loop.
Diffstat (limited to 'alot/ui.py')
-rw-r--r-- | alot/ui.py | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -6,8 +6,9 @@ import os import signal import codecs import contextlib +import asyncio -from twisted.internet import reactor, defer, task +from twisted.internet import defer, task import urwid from .settings.const import settings @@ -105,7 +106,7 @@ class UI(object): self.mainloop = urwid.MainLoop( self.root_widget, handle_mouse=settings.get('handle_mouse'), - event_loop=urwid.TwistedEventLoop(), + event_loop=urwid.AsyncioEventLoop(), unhandled_input=self._unhandled_input, input_filter=self._input_filter) @@ -359,10 +360,11 @@ class UI(object): """ exit_msg = None try: - reactor.stop() + loop = asyncio.get_event_loop() + loop.stop() except Exception as e: - exit_msg = 'Could not stop reactor: {}.'.format(e) - logging.error('%s\nShutting down anyway..', exit_msg) + logging.error('Could not stop loop: %s\nShutting down anyway..', + str(e)) @contextlib.contextmanager def paused(self): |