From 6b53bf43d212ad34b110f7768d5f96c69d371bdc Mon Sep 17 00:00:00 2001 From: jiangweidong <1053570670@qq.com> Date: Thu, 12 Sep 2024 09:45:45 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/behemoth/libs/parser/handle.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/behemoth/libs/parser/handle.py b/apps/behemoth/libs/parser/handle.py index 38aab7fa6b81..46ce8dce97be 100644 --- a/apps/behemoth/libs/parser/handle.py +++ b/apps/behemoth/libs/parser/handle.py @@ -9,7 +9,7 @@ from common.utils import get_logger -if platform.system() == "Darwin": +if platform.system() == 'Darwin': so_dir = 'parse_darwin.so' else: so_dir = 'parse_linux.so' @@ -17,9 +17,12 @@ logger = get_logger(__file__) -lib = ctypes.CDLL(os.path.join(settings.APPS_DIR, 'behemoth', 'libs', 'parser', so_dir)) -lib.Parse.argtypes = [ctypes.c_char_p] # noqa -lib.Parse.restype = ctypes.c_char_p +try: + lib = ctypes.CDLL(os.path.join(settings.APPS_DIR, 'behemoth', 'libs', 'parser', so_dir)) + lib.Parse.argtypes = [ctypes.c_char_p] # noqa + lib.Parse.restype = ctypes.c_char_p +except Exception as error: + logger.error('Failed to load parse lib') def parse_sql(sql: str) -> List[str]: