mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 17:20:30 +08:00
shield some finally ops
This commit is contained in:
parent
9ee63aba3e
commit
eeaeebf7c7
@ -354,9 +354,17 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
|||||||
yield self.__reader
|
yield self.__reader
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
await self.__close_reader()
|
# FIXME: Перехват важен потому что по какой-то причине await
|
||||||
|
# во вложенных finally путаются и выполняются не по порядку
|
||||||
|
try:
|
||||||
|
await asyncio.shield(self.__close_reader())
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
finally:
|
finally:
|
||||||
await self.__notifier.notify()
|
try:
|
||||||
|
await asyncio.shield(self.__notifier.notify())
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
|
|
||||||
@contextlib.asynccontextmanager
|
@contextlib.asynccontextmanager
|
||||||
async def write_image(self, name: str, size: int, remove_incomplete: Optional[bool]) -> AsyncGenerator[MsdFileWriter, None]:
|
async def write_image(self, name: str, size: int, remove_incomplete: Optional[bool]) -> AsyncGenerator[MsdFileWriter, None]:
|
||||||
@ -398,13 +406,25 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
|||||||
os.remove(path)
|
os.remove(path)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
await self.__close_writer()
|
try:
|
||||||
await self.__remount_rw(False, fatal=False)
|
await asyncio.shield(self.__close_writer())
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
await asyncio.shield(self.__remount_rw(False, fatal=False))
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
finally:
|
finally:
|
||||||
# Между закрытием файла и эвентом айнотифи состояние может быть не обновлено,
|
# Между закрытием файла и эвентом айнотифи состояние может быть не обновлено,
|
||||||
# так что форсим обновление вручную, чтобы получить актуальное состояние.
|
# так что форсим обновление вручную, чтобы получить актуальное состояние.
|
||||||
await self.__reload_state()
|
try:
|
||||||
await self.__notifier.notify()
|
await asyncio.shield(self.__reload_state())
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
await asyncio.shield(self.__notifier.notify())
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
|
|
||||||
@aiotools.atomic
|
@aiotools.atomic
|
||||||
async def remove(self, name: str) -> None:
|
async def remove(self, name: str) -> None:
|
||||||
|
|||||||
@ -249,8 +249,14 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
|
|||||||
yield self.__device_writer
|
yield self.__device_writer
|
||||||
await self.__write_image_info(True)
|
await self.__write_image_info(True)
|
||||||
finally:
|
finally:
|
||||||
await self.__close_device_writer()
|
try:
|
||||||
await self.__load_device_info()
|
await asyncio.shield(self.__close_device_writer())
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
await asyncio.shield(self.__load_device_info())
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
pass
|
||||||
|
|
||||||
@aiotools.atomic
|
@aiotools.atomic
|
||||||
async def remove(self, name: str) -> None:
|
async def remove(self, name: str) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user