def run(self, work): failure = None started_at = self.now_func() try: work() except Exception: # Until https://bugs.python.org/issue24451 is merged we have to # capture and return the failure, so that we can have reliable # timing information. failure = utils.Failure(self.retain_traceback) finished_at = self.now_func() return (started_at, finished_at, failure)
def _run_callback_no_retain(now_func, cb, *args, **kwargs): # NOTE(harlowja): this needs to be a module level function so that the # process pool execution can locate it (it can't be a lambda or method # local function because it won't be able to find those). failure = None started_at = now_func() try: cb(*args, **kwargs) except Exception: # Until https://bugs.python.org/issue24451 is merged we have to # capture and return the failure, so that we can have reliable # timing information. failure = utils.Failure(False) finished_at = now_func() return (started_at, finished_at, failure)