Title: Implement minimal core framework with PL injection and update build config
Key features implemented: - Updated package metadata and dependencies in PKG-INFO, setup files - Added main.py entry point for backward compatibility with README launch method - Enhanced CLI with config options, system info command, and proper signal handling - Implemented minimal PluginManager loading only plugin-loader core plugin - Refactored PluginLoader to follow minimal core design, removed sandbox/isolation complexity - Updated auto-dependency plugin with safer PL injection mechanism and disabled pl_injection - Removed legacy plugin files (firewall, frp_proxy, ftp_server, multi_lang_deploy, ops_toolbox, security_gateway) as functionality moved to core plugin system - Improved gitignore with comprehensive ignore patterns The changes implement a minimal core framework design where only the plugin-loader is directly loaded by the core, with all other plugins managed through the PL injection mechanism, significantly simplifying the architecture.
This commit is contained in:
29
store/@{FutureOSS}/plugin-loader-pro/isolation/timeout.py
Normal file
29
store/@{FutureOSS}/plugin-loader-pro/isolation/timeout.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""超时控制"""
|
||||
import signal
|
||||
|
||||
|
||||
class TimeoutError(Exception):
|
||||
"""超时错误"""
|
||||
pass
|
||||
|
||||
|
||||
class TimeoutController:
|
||||
"""超时控制器"""
|
||||
|
||||
def __init__(self, timeout: int = 30):
|
||||
self.timeout = timeout
|
||||
|
||||
def execute_with_timeout(self, func, *args, **kwargs) -> any:
|
||||
"""在超时限制内执行函数"""
|
||||
def handler(signum, frame):
|
||||
raise TimeoutError(f"执行超时 (>{self.timeout}s)")
|
||||
|
||||
old_handler = signal.signal(signal.SIGALRM, handler)
|
||||
signal.alarm(self.timeout)
|
||||
|
||||
try:
|
||||
result = func(*args, **kwargs)
|
||||
signal.alarm(0)
|
||||
return result
|
||||
finally:
|
||||
signal.signal(signal.SIGALRM, old_handler)
|
||||
Reference in New Issue
Block a user