mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 01:30:31 +08:00
fixed lock behaviour in read_image()
This commit is contained in:
parent
049ea642dc
commit
d05b46e05d
@ -329,7 +329,11 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
|||||||
|
|
||||||
@contextlib.asynccontextmanager
|
@contextlib.asynccontextmanager
|
||||||
async def read_image(self, name: str) -> AsyncGenerator[int, None]:
|
async def read_image(self, name: str) -> AsyncGenerator[int, None]:
|
||||||
async with self.__state.busy():
|
try:
|
||||||
|
async with self.__state._region: # pylint: disable=protected-access
|
||||||
|
try:
|
||||||
|
async with self.__state._lock: # pylint: disable=protected-access
|
||||||
|
await self.__notifier.notify()
|
||||||
assert self.__state.storage
|
assert self.__state.storage
|
||||||
assert self.__state.vd
|
assert self.__state.vd
|
||||||
|
|
||||||
@ -340,11 +344,14 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
|||||||
if name not in self.__state.storage.images or not os.path.exists(path):
|
if name not in self.__state.storage.images or not os.path.exists(path):
|
||||||
raise MsdUnknownImageError()
|
raise MsdUnknownImageError()
|
||||||
|
|
||||||
try:
|
|
||||||
self.__reader = await MsdImageReader(path, self.__read_chunk_size).open()
|
self.__reader = await MsdImageReader(path, self.__read_chunk_size).open()
|
||||||
|
|
||||||
yield self.__reader.get_size()
|
yield self.__reader.get_size()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
await self.__close_reader()
|
await self.__close_reader()
|
||||||
|
finally:
|
||||||
|
await self.__notifier.notify()
|
||||||
|
|
||||||
async def read_image_chunk(self) -> bytes:
|
async def read_image_chunk(self) -> bytes:
|
||||||
assert self.__reader
|
assert self.__reader
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user