Skip to content

Commit

Permalink
perf: 优化解析脚本导入
Browse files Browse the repository at this point in the history
  • Loading branch information
O-Jiangweidong committed Sep 12, 2024
1 parent 94ef440 commit 6b53bf4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions apps/behemoth/libs/parser/handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@
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'


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]:
Expand Down

0 comments on commit 6b53bf4

Please sign in to comment.