stop swallowing exceptions raised by the callback passed to run_in_bg

it is just more confusing that it is worth, especially when doing
development
This commit is contained in:
Michael Hudson-Doyle 2018-05-18 12:16:41 +12:00
parent 13d7f13c42
commit 03392a208d
1 changed files with 3 additions and 6 deletions

View File

@ -49,15 +49,12 @@ class BaseController(ABC):
"""Run func() in a thread and call callback on UI thread.
callback will be passed a concurrent.futures.Future containing
the result of func(). The result of callback is discarded. Any
exception will be logged.
the result of func(). The result of callback is discarded. An
exception will crash the process so be careful!
"""
fut = self.pool.submit(func)
def in_main_thread(ignored):
try:
callback(fut)
except:
log.exception("callback %s after calling %s failed", callback, func)
callback(fut)
pipe = self.loop.watch_pipe(in_main_thread)
def in_random_thread(ignored):
os.write(pipe, b'x')