Skip to content

Commit

Permalink
Fix urwid stalling until input received
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabunek committed Dec 19, 2023
1 parent 561506e commit d9c6bf7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions toot/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ def build_intro(self):

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
Expand All @@ -197,7 +197,10 @@ def _done(future):
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

Expand Down

0 comments on commit d9c6bf7

Please sign in to comment.