def catch_pickleerror(reason, job, workr): """ Treat pickling errors as errors thrown by the user's code. """ if reason.check(pickle.PickleError): return traverser.EvalResult(reason, 0) else: return reason
def test_get_task_state_evaluated(self): g = G( T(1, tasks.ConstTask(None)), C(1, "value", 2, "in"), T(2, "task"), C(2, "out", FINAL_TICK, "retval") ) self.target.execute(g, {}) self.next_ready()[-1].callback(traverser.EvalResult({"value":"Hello"})) self.assertEqual(traverser.TaskState.EVALUATED, self.target.get_task_state(TICK1))
def test_finish(self): g = G( T(1, tasks.ConstTask(None)), C(1, "value", FINAL_TICK, "retval") ) d = self.target.execute(g, {}) self.next_ready()[-1].callback(traverser.EvalResult({"value":"Hello"})) outputs = extract(d) self.assertEqual({"retval":"Hello"}, outputs)
def test_injest_result(self): g = G( T(1, tasks.ConstTask(None)), C(1, "value", 2, "in"), T(2, "task"), C(2, "out", FINAL_TICK, "retval") ) self.target.execute(g, {}) self.next_ready()[-1].callback(traverser.EvalResult({"value":"Hello"})) self.assertEqual((TICK2, "task", {"in":"Hello"}), self.next_ready()[1:-1])
def run(inputs): """ Runs in separate thread. """ start = time.clock() try: result = task.evaluate(inputs) except: result = failure.Failure() finally: end = time.clock() return traverser.EvalResult(result, end - start)
def run(inputs): """ Runs in separate thread. """ logger.debug("Running job %s" % tick) #start = time.clock() start = datetime.datetime.now() try: result = task.evaluate(inputs) except: result = failure.Failure() finally: #end = time.clock() end = datetime.datetime.now() logger.debug("Running job %s finished" % tick) #duration = end - start duration = (end - start).total_seconds() return traverser.EvalResult(result, duration)