错误如下:
Database error
Instance <Query at 0x20e37215850> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/bhk3)
解决方法:
这个问题貌似是因为signalalarm,需要对源码做出如下变动:
首先打开superset的目录,找到core.py文件,我的是在C:\Python38\Lib\site-packages\superset\utils下
找到如下代码:
def __enter__(self) -> None:
try:
if threading.current_thread() == threading.main_thread():
signal.signal(signal.SIGALRM, self.handle_timeout)
signal.alarm(self.seconds)
except ValueError as ex:
logger.warning("timeout can't be used in the current context")
logger.exception(ex)
def __exit__( # pylint: disable=redefined-outer-name,unused-variable,redefined-builtin
self, type: Any, value: Any, traceback: TracebackType
) -> None:
try:
signal.alarm(0)
except ValueError as ex:
logger.warning("timeout can't be used in the current context")
logger.exception(ex)
修改成:
def __enter__(self) -> None:
try:
if threading.current_thread() == threading.main_thread():
# signal.signal(signal.SIGALRM, self.handle_timeout)
# signal.alarm(self.seconds)
pass
except ValueError as ex:
logger.warning("timeout can't be used in the current context")
logger.exception(ex)
def __exit__( # pylint: disable=redefined-outer-name,unused-variable,redefined-builtin
self, type: Any, value: Any, traceback: TracebackType
) -> None:
try:
# signal.alarm(0)
pass
except ValueError as ex:
logger.warning("timeout can't be used in the current context")
logger.exception(ex)
保存,重新运行即可
原文:https://github.com/apache/superset/discussions/13169