async_gui
async_gui copied to clipboard
When an exception occurs in a future, we lose most of the traceback
Consider the following:
def bad():
worse()
def worse():
raise RuntimeError("Bad Day")
Currently, if this code gets executed in a Task, we'll lose the traceback, only the last line will show up. When I ran across this problem with Python Futures in my own code, I came up with a janky solution with a subclassed Executor class, perhaps you can think of something better than this for async_gui, which is awesome btw, thank you.
class CustomExecutor(concurrent.futures.thread.ThreadPoolExecutor):
def submit(self, task, *args, **kwargs):
@functools.wraps(task)
def task_wrapper():
try:
return task(*args, **kwargs)
except Exception as e:
logger.exception("Error executing %r with args %r and kwargs %r" % (task, args, kwargs))
raise
future = super(CustomExecutor, self).submit(task_wrapper)
return future