<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _wrapper(self):
 """ Wraps around a few calls which need to be made in the same thread. """

        try:
            res = self.func(*self.args, **self.kw)
        except Exception as e:
            self.mediator.set_error(e)
        else:
            self.mediator.set_result(res)