summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-01-20 13:17:51 +0100
committerAnton Khirnov <anton@khirnov.net>2021-01-20 13:17:51 +0100
commitcfb29a7cd442b3b6a969561d0d27f52d5c2dba78 (patch)
tree358783e494da1724b67f79769a5b440099fbfea3
parentd47a85bca83352300399f04e76abecea4d53a934 (diff)
ui: clean up asyncio calls
Bump python dependency to 3.7, which added create_task().
-rw-r--r--alot/ui.py15
-rwxr-xr-xsetup.py3
2 files changed, 7 insertions, 11 deletions
diff --git a/alot/ui.py b/alot/ui.py
index 550ca150..b8bcae5f 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -259,8 +259,7 @@ class UI:
clear()
logging.debug("cmdline: '%s'", cmdline)
if not self._locked:
- loop = asyncio.get_event_loop()
- loop.create_task(_apply_fire(cmdline))
+ self._loop.create_task(_apply_fire(cmdline))
# move keys are always passed
elif cmdline in ['move up', 'move down', 'move page up',
'move page down']:
@@ -378,7 +377,7 @@ class UI:
"""
history = history or []
- fut = asyncio.get_event_loop().create_future()
+ fut = self._loop.create_future()
oldroot = self.mainloop.widget
def select_or_cancel(text):
@@ -424,15 +423,13 @@ class UI:
self._passall = True
return fut
- @staticmethod
- def exit():
+ def exit(self):
"""
shuts down user interface without cleaning up.
Use a :class:`alot.commands.globals.ExitCommand` for a clean shutdown.
"""
try:
- loop = asyncio.get_event_loop()
- loop.stop()
+ self._loop.stop()
except Exception as e:
logging.error('Could not stop loop: %s\nShutting down anyway..',
str(e))
@@ -586,7 +583,7 @@ class UI:
assert cancel is None or cancel in choices.values()
assert msg_position in ['left', 'above']
- fut = asyncio.get_event_loop().create_future() # Create a returned future
+ fut = self._loop.create_future()
oldroot = self.mainloop.widget
def select_or_cancel(text):
@@ -745,7 +742,7 @@ class UI:
# it is a SIGINT ?
if signum == signal.SIGINT:
logging.info('shut down cleanly')
- asyncio.ensure_future(self.apply_command(globals.ExitCommand()))
+ asyncio.create_task(self.apply_command(globals.ExitCommand()))
elif signum == signal.SIGUSR1:
if isinstance(self.current_buffer, SearchBuffer):
self.current_buffer.rebuild()
diff --git a/setup.py b/setup.py
index fbeb79f5..56b9f894 100755
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,6 @@ setup(
'License :: OSI Approved'
':: GNU General Public License v3 or later (GPLv3+)'),
'Operating System :: POSIX',
- 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Communications :: Email :: Email Clients (MUA)',
@@ -53,5 +52,5 @@ setup(
],
provides=['alot'],
test_suite="tests",
- python_requires=">=3.6",
+ python_requires=">=3.7",
)