Merge pull request #41 from happyhaha1/master

feat(lua): enhance runtime environment with resilient module loading
This commit is contained in:
Yingqi Tang
2025-10-31 22:54:17 +08:00
committed by GitHub

View File

@@ -1,6 +1,6 @@
import os import os
import traceback import traceback
import os
import lupa import lupa
import threading import threading
import json import json
@@ -20,12 +20,12 @@ class LuaRuntime:
self._runtimes.execute('require "cjson"') self._runtimes.execute('require "cjson"')
except Exception as e: except Exception as e:
MideaLogger.warning(f"Failed to load cjson: {e}") MideaLogger.warning(f"Failed to load cjson: {e}")
try: try:
self._runtimes.execute('require "bit"') self._runtimes.execute('require "bit"')
except Exception as e: except Exception as e:
MideaLogger.warning(f"Failed to load bit: {e}") MideaLogger.warning(f"Failed to load bit: {e}")
# 加载设备特定的Lua文件 # 加载设备特定的Lua文件
string = f'dofile("{file}")' string = f'dofile("{file}")'
self._runtimes.execute(string) self._runtimes.execute(string)