From 7e56c3fd4944768277938199cf66ac2643370e15 Mon Sep 17 00:00:00 2001 From: nanoric Date: Tue, 9 Oct 2018 06:06:23 -0400 Subject: [PATCH] =?UTF-8?q?[Mod]=20Promise:=E5=A2=9E=E5=8A=A0=E5=AF=B9trac?= =?UTF-8?q?eback=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Promise.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/Promise.py b/tests/Promise.py index 51aab6b6..ca8e2813 100644 --- a/tests/Promise.py +++ b/tests/Promise.py @@ -7,6 +7,7 @@ from enum import Enum class PromiseResultType(Enum): Result = 1 Exception = 2 + Traceback = 3 class Promise(object): @@ -24,7 +25,14 @@ class Promise(object): res = self._queue.get(timeout=timeout) if res[0] == PromiseResultType.Result: return res[1] - raise res[1] + elif res[0] == PromiseResultType.Exception: + raise res[1] + else: + et, ev, tb = res[1] + raise et, ev, tb - def set_exception(self, val): - self._queue.put((PromiseResultType.Exception, val)) + def set_exception(self, valueOrType, val=None, tb=None): + if val is None: + self._queue.put((PromiseResultType.Exception, val)) + else: + self._queue.put((PromiseResultType.Traceback, (valueOrType, val, tb)))