def __call__(self, request): func = data_funcs[request.type] if is_gui_thread(): try: return func(request.data), None except Exception: import traceback return None, traceback.format_exc() self.called.clear() self.call.emit(func, request.data) self.called.wait() try: return self.result, self.tb finally: del self.result, self.tb