mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
Merge pull request #1508 from xinnan-tech/hot-fix
update:修复windows平台无法使用fcntl模块的问题
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user