Add traceback property to AnyIOTaskResult class
This commit is contained in:
parent
87f8af1db9
commit
2edacce305
1 changed files with 11 additions and 1 deletions
|
|
@ -1,8 +1,11 @@
|
||||||
|
import traceback
|
||||||
from typing import Any, Callable, Optional, Tuple
|
from typing import Any, Callable, Optional, Tuple
|
||||||
|
|
||||||
import anyio
|
import anyio
|
||||||
from langflow.services.task.backends.base import TaskBackend
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
from langflow.services.task.backends.base import TaskBackend
|
||||||
|
|
||||||
|
|
||||||
class AnyIOTaskResult:
|
class AnyIOTaskResult:
|
||||||
def __init__(self, scope):
|
def __init__(self, scope):
|
||||||
|
|
@ -17,6 +20,12 @@ class AnyIOTaskResult:
|
||||||
return "FAILURE" if self._exception is not None else "SUCCESS"
|
return "FAILURE" if self._exception is not None else "SUCCESS"
|
||||||
return self._status
|
return self._status
|
||||||
|
|
||||||
|
@property
|
||||||
|
def traceback(self) -> str:
|
||||||
|
if self._traceback is not None:
|
||||||
|
return "".join(traceback.format_tb(self._traceback))
|
||||||
|
return ""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def result(self) -> Any:
|
def result(self) -> Any:
|
||||||
return self._result
|
return self._result
|
||||||
|
|
@ -29,6 +38,7 @@ class AnyIOTaskResult:
|
||||||
self._result = await func(*args, **kwargs)
|
self._result = await func(*args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._exception = e
|
self._exception = e
|
||||||
|
self._traceback = e.__traceback__
|
||||||
finally:
|
finally:
|
||||||
self._status = "DONE"
|
self._status = "DONE"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue