临时提交
This commit is contained in:
@@ -71,6 +71,17 @@ def _pick_free_port(low: int = 20000, high: int = 48000) -> int:
|
|||||||
|
|
||||||
|
|
||||||
class DeviceInfo:
|
class DeviceInfo:
|
||||||
|
_instance = None
|
||||||
|
_instance_lock = threading.Lock()
|
||||||
|
|
||||||
|
def __new__(cls, *args, **kwargs):
|
||||||
|
# 双重检查锁,确保线程安全单例
|
||||||
|
if not cls._instance:
|
||||||
|
with cls._instance_lock:
|
||||||
|
if not cls._instance:
|
||||||
|
cls._instance = super().__new__(cls)
|
||||||
|
return cls._instance
|
||||||
|
|
||||||
# ---- 端口分配:加一个最小的“保留池”,避免并发选到同一个端口 ----
|
# ---- 端口分配:加一个最小的“保留池”,避免并发选到同一个端口 ----
|
||||||
def _alloc_port(self) -> int:
|
def _alloc_port(self) -> int:
|
||||||
with self._lock:
|
with self._lock:
|
||||||
@@ -105,6 +116,10 @@ class DeviceInfo:
|
|||||||
WDA_READY_TIMEOUT = float(os.getenv("WDA_READY_TIMEOUT", "35.0"))
|
WDA_READY_TIMEOUT = float(os.getenv("WDA_READY_TIMEOUT", "35.0"))
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
# 防止多次初始化(因为 __init__ 每次调用 DeviceInfo() 都会执行)
|
||||||
|
if getattr(self, "_initialized", False):
|
||||||
|
return
|
||||||
|
|
||||||
self._lock = threading.RLock()
|
self._lock = threading.RLock()
|
||||||
self._models: Dict[str, DeviceModel] = {}
|
self._models: Dict[str, DeviceModel] = {}
|
||||||
self._iproxy: Dict[str, subprocess.Popen] = {}
|
self._iproxy: Dict[str, subprocess.Popen] = {}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ from pathlib import Path
|
|||||||
from typing import Optional, Union, Dict, List
|
from typing import Optional, Union, Dict, List
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
from Utils.LogManager import LogManager
|
from Utils.LogManager import LogManager
|
||||||
|
|
||||||
|
|
||||||
@@ -173,6 +172,11 @@ class FlaskSubprocessManager:
|
|||||||
self.stop()
|
self.stop()
|
||||||
try:
|
try:
|
||||||
self.start()
|
self.start()
|
||||||
|
from Module.DeviceInfo import DeviceInfo
|
||||||
|
# 重新发送设备相关数据到flask
|
||||||
|
info = DeviceInfo()
|
||||||
|
for model in info._models.keys():
|
||||||
|
self.send(model)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LogManager.error(f"自动重启失败:{e}", udid="system")
|
LogManager.error(f"自动重启失败:{e}", udid="system")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ if __name__ == "__main__":
|
|||||||
# 清空日志
|
# 清空日志
|
||||||
LogManager.clearLogs()
|
LogManager.clearLogs()
|
||||||
|
|
||||||
main(sys.argv)
|
# main(sys.argv)
|
||||||
|
|
||||||
# 添加iOS开发包到电脑上
|
# 添加iOS开发包到电脑上
|
||||||
deployer = DevDiskImageDeployer(verbose=True)
|
deployer = DevDiskImageDeployer(verbose=True)
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -26,7 +26,7 @@ def _force_utf8_everywhere():
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
_force_utf8_everywhere()
|
# _force_utf8_everywhere()
|
||||||
|
|
||||||
class LogManager:
|
class LogManager:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user