summaryrefslogtreecommitdiff
path: root/kvmd/plugins
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-08-07 19:18:23 +0300
committerMaxim Devaev <[email protected]>2022-08-07 19:18:23 +0300
commitfdc3edfa799b21f04a83676459bab7a4e67b056f (patch)
tree9c91c905c241094bfde6a620cc81b476a9f3f9ab /kvmd/plugins
parent1d4b39ef1b039e7eeb2ceca74a7f9d40bfbeb0c0 (diff)
using shield_fg()
Diffstat (limited to 'kvmd/plugins')
-rw-r--r--kvmd/plugins/msd/otg/__init__.py22
-rw-r--r--kvmd/plugins/msd/relay/__init__.py10
2 files changed, 8 insertions, 24 deletions
diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py
index 8d1ee8a5..cb781fae 100644
--- a/kvmd/plugins/msd/otg/__init__.py
+++ b/kvmd/plugins/msd/otg/__init__.py
@@ -354,12 +354,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
yield self.__reader
finally:
- # FIXME: Перехват важен потому что по какой-то причине await
- # во вложенных finally путаются и выполняются не по порядку
- try:
- await asyncio.shield(self.__close_reader())
- except asyncio.CancelledError:
- pass
+ await aiotools.shield_fg(self.__close_reader())
finally:
self.__notifier.notify()
@@ -404,20 +399,13 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
except Exception:
pass
try:
- await asyncio.shield(self.__close_writer())
- except asyncio.CancelledError:
- pass
- try:
- await asyncio.shield(self.__remount_rw(False, fatal=False))
- except asyncio.CancelledError:
- pass
+ await aiotools.shield_fg(self.__close_writer())
+ finally:
+ await aiotools.shield_fg(self.__remount_rw(False, fatal=False))
finally:
# Между закрытием файла и эвентом айнотифи состояние может быть не обновлено,
# так что форсим обновление вручную, чтобы получить актуальное состояние.
- try:
- await asyncio.shield(self.__reload_state())
- except asyncio.CancelledError:
- pass
+ await aiotools.shield_fg(self.__reload_state())
@aiotools.atomic
async def remove(self, name: str) -> None:
diff --git a/kvmd/plugins/msd/relay/__init__.py b/kvmd/plugins/msd/relay/__init__.py
index f6b13dc5..febc3750 100644
--- a/kvmd/plugins/msd/relay/__init__.py
+++ b/kvmd/plugins/msd/relay/__init__.py
@@ -250,13 +250,9 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
await self.__write_image_info(True)
finally:
try:
- await asyncio.shield(self.__close_device_writer())
- except asyncio.CancelledError:
- pass
- try:
- await asyncio.shield(self.__load_device_info())
- except asyncio.CancelledError:
- pass
+ await aiotools.shield_fg(self.__close_device_writer())
+ finally:
+ await aiotools.shield_fg(self.__load_device_info())
@aiotools.atomic
async def remove(self, name: str) -> None: