1
0
mirror of https://github.com/ihabunek/toot.git synced 2024-11-03 04:17:21 -05:00

Merge branch 'master' into images

This commit is contained in:
Daniel Schwarz 2023-12-19 10:04:09 -05:00
commit 76d8a27a85

View File

@ -183,8 +183,8 @@ class TUI(urwid.Frame):
return urwid.Filler(intro)
def run_in_thread(self, fn, args=[], kwargs={}, done_callback=None, error_callback=None):
"""Runs `fn(*args, **kwargs)` asynchronously in a separate thread.
def run_in_thread(self, fn, done_callback=None, error_callback=None):
"""Runs `fn` asynchronously in a separate thread.
On completion calls `done_callback` if `fn` exited cleanly, or
`error_callback` if an exception was caught. Callback methods are
@ -208,7 +208,10 @@ class TUI(urwid.Frame):
logger.exception(exception)
self.loop.set_alarm_in(0, lambda *args: _error_callback(exception))
future = self.executor.submit(fn, *args, **kwargs)
# TODO: replace by `self.loop.event_loop.run_in_executor` at some point
# Added in https://github.com/urwid/urwid/issues/575
# Not yet released at the time of this comment
future = self.loop.event_loop._loop.run_in_executor(self.executor, fn)
future.add_done_callback(_done)
return future