Merge pull request #1508 from xinnan-tech/hot-fix

update:修复windows平台无法使用fcntl模块的问题
This commit is contained in:
欣南科技
2025-06-08 00:21:27 +08:00
committed by GitHub
2 changed files with 6 additions and 6 deletions
@@ -2,9 +2,8 @@ import os
import yaml
import time
import hashlib
import fcntl
import portalocker
from typing import Dict
from contextlib import contextmanager
class FileLock:
@@ -17,15 +16,15 @@ class FileLock:
self.start_time = time.time()
while True:
try:
fcntl.flock(self.file, fcntl.LOCK_EX | fcntl.LOCK_NB)
portalocker.lock(self.file, portalocker.LOCK_EX | portalocker.LOCK_NB)
return self.file
except IOError:
except portalocker.LockException:
if time.time() - self.start_time > self.timeout:
raise TimeoutError("获取文件锁超时")
time.sleep(0.1)
def __exit__(self, exc_type, exc_val, exc_tb):
fcntl.flock(self.file, fcntl.LOCK_UN)
portalocker.unlock(self.file)
class WakeupWordsConfig:
+2 -1
View File
@@ -32,4 +32,5 @@ aioconsole==0.8.1
markitdown==0.1.1
mcp-proxy==0.6.0
PyJWT==2.8.0
psutil==7.0.0
psutil==7.0.0
portalocker==2.10.1