t{daemon,wallet}|.stop: small clean-up - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit de6f5a8e0357b201b5f0ffe20195b36cad66824d DIR parent eaa4de33541a56af049b8d48b92f206ed47f785a HTML Author: SomberNight <somber.night@protonmail.com> Date: Wed, 10 Mar 2021 18:07:15 +0100 {daemon,wallet}|.stop: small clean-up Diffstat: M electrum/daemon.py | 17 ++++++----------- M electrum/wallet.py | 6 ++---- 2 files changed, 8 insertions(+), 15 deletions(-) --- DIR diff --git a/electrum/daemon.py b/electrum/daemon.py t@@ -32,13 +32,11 @@ import threading from typing import Dict, Optional, Tuple, Iterable, Callable, Union, Sequence, Mapping, TYPE_CHECKING from base64 import b64decode, b64encode from collections import defaultdict -import concurrent -from concurrent import futures import json import aiohttp from aiohttp import web, client_exceptions -from aiorpcx import TaskGroup, timeout_after, TaskTimeout +from aiorpcx import TaskGroup, timeout_after, TaskTimeout, ignore_after from . import util from .network import Network t@@ -560,14 +558,11 @@ class Daemon(Logger): for k, wallet in self._wallets.items(): await group.spawn(wallet.stop()) self.logger.info("stopping network and taskgroup") - try: - async with timeout_after(2): - async with TaskGroup() as group: - if self.network: - await group.spawn(self.network.stop(full_shutdown=True)) - await group.spawn(self.taskgroup.cancel_remaining()) - except TaskTimeout: - pass + async with ignore_after(2): + async with TaskGroup() as group: + if self.network: + await group.spawn(self.network.stop(full_shutdown=True)) + await group.spawn(self.taskgroup.cancel_remaining()) fut = asyncio.run_coroutine_threadsafe(stop_async(), self.asyncio_loop) fut.result() DIR diff --git a/electrum/wallet.py b/electrum/wallet.py t@@ -46,7 +46,7 @@ import itertools import threading import enum -from aiorpcx import TaskGroup, timeout_after, TaskTimeout +from aiorpcx import TaskGroup, timeout_after, TaskTimeout, ignore_after from .i18n import _ from .bip32 import BIP32Node, convert_bip32_intpath_to_strpath, convert_bip32_path_to_list_of_uint32 t@@ -357,14 +357,12 @@ class Abstract_Wallet(AddressSynchronizer, ABC): async def stop(self): """Stop all networking and save DB to disk.""" try: - async with timeout_after(5): + async with ignore_after(5): await super().stop() if self.network: if self.lnworker: await self.lnworker.stop() self.lnworker = None - except TaskTimeout: - pass finally: # even if we get cancelled if any([ks.is_requesting_to_be_rewritten_to_wallet_file for ks in self.get_keystores()]): self.save_keystore()