util: rm SilentTaskGroup. this does not seem to be needed anymore
I think this was originally needed due to incorrect management of group lifecycles,
which our current code is doing better.
also note that if we needed this, in newer aiorpcx, the name of
the field was ~changed from `_closed` to `joined`:
239002689a
This commit is contained in:
@@ -45,7 +45,7 @@ from aiorpcx.jsonrpc import JSONRPC, CodeMessageError
|
||||
from aiorpcx.rawsocket import RSClient
|
||||
import certifi
|
||||
|
||||
from .util import (ignore_exceptions, log_exceptions, bfh, SilentTaskGroup, MySocksProxy,
|
||||
from .util import (ignore_exceptions, log_exceptions, bfh, MySocksProxy,
|
||||
is_integer, is_non_negative_integer, is_hash256_str, is_hex_str,
|
||||
is_int_or_float, is_non_negative_int_or_float)
|
||||
from . import util
|
||||
@@ -376,7 +376,7 @@ class Interface(Logger):
|
||||
# Dump network messages (only for this interface). Set at runtime from the console.
|
||||
self.debug = False
|
||||
|
||||
self.taskgroup = SilentTaskGroup()
|
||||
self.taskgroup = TaskGroup()
|
||||
|
||||
async def spawn_task():
|
||||
task = await self.network.taskgroup.spawn(self.run())
|
||||
|
||||
@@ -21,7 +21,7 @@ from . import bitcoin, util
|
||||
from . import ecc
|
||||
from .ecc import sig_string_from_r_and_s, der_sig_from_sig_string
|
||||
from . import constants
|
||||
from .util import (bh2u, bfh, log_exceptions, ignore_exceptions, chunks, SilentTaskGroup,
|
||||
from .util import (bh2u, bfh, log_exceptions, ignore_exceptions, chunks, TaskGroup,
|
||||
UnrelatedTransactionException)
|
||||
from . import transaction
|
||||
from .bitcoin import make_op_return
|
||||
@@ -105,7 +105,7 @@ class Peer(Logger):
|
||||
self.announcement_signatures = defaultdict(asyncio.Queue)
|
||||
self.orphan_channel_updates = OrderedDict() # type: OrderedDict[ShortChannelID, dict]
|
||||
Logger.__init__(self)
|
||||
self.taskgroup = SilentTaskGroup()
|
||||
self.taskgroup = TaskGroup()
|
||||
# HTLCs offered by REMOTE, that we started removing but are still active:
|
||||
self.received_htlcs_pending_removal = set() # type: Set[Tuple[Channel, int]]
|
||||
self.received_htlc_removed_event = asyncio.Event()
|
||||
|
||||
@@ -39,7 +39,7 @@ from .crypto import sha256
|
||||
from .bip32 import BIP32Node
|
||||
from .util import bh2u, bfh, InvoiceError, resolve_dns_srv, is_ip_address, log_exceptions
|
||||
from .crypto import chacha20_encrypt, chacha20_decrypt
|
||||
from .util import ignore_exceptions, make_aiohttp_session, SilentTaskGroup
|
||||
from .util import ignore_exceptions, make_aiohttp_session
|
||||
from .util import timestamp_to_datetime, random_shuffled_copy
|
||||
from .util import MyEncoder, is_private_netaddress
|
||||
from .logging import Logger
|
||||
@@ -200,7 +200,7 @@ class LNWorker(Logger, NetworkRetryManager[LNPeerAddr]):
|
||||
self.node_keypair = generate_keypair(BIP32Node.from_xkey(xprv), LnKeyFamily.NODE_KEY)
|
||||
self.backup_key = generate_keypair(BIP32Node.from_xkey(xprv), LnKeyFamily.BACKUP_CIPHER).privkey
|
||||
self._peers = {} # type: Dict[bytes, Peer] # pubkey -> Peer # needs self.lock
|
||||
self.taskgroup = SilentTaskGroup()
|
||||
self.taskgroup = TaskGroup()
|
||||
self.listen_server = None # type: Optional[asyncio.AbstractServer]
|
||||
self.features = features
|
||||
self.network = None # type: Optional[Network]
|
||||
|
||||
@@ -45,7 +45,7 @@ from aiohttp import ClientResponse
|
||||
|
||||
from . import util
|
||||
from .util import (log_exceptions, ignore_exceptions,
|
||||
bfh, SilentTaskGroup, make_aiohttp_session, send_exception_to_crash_reporter,
|
||||
bfh, make_aiohttp_session, send_exception_to_crash_reporter,
|
||||
is_hash256_str, is_non_negative_integer, MyEncoder, NetworkRetryManager,
|
||||
nullcontext)
|
||||
from .bitcoin import COIN
|
||||
@@ -1184,7 +1184,7 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
|
||||
|
||||
async def _start(self):
|
||||
assert not self.taskgroup
|
||||
self.taskgroup = taskgroup = SilentTaskGroup()
|
||||
self.taskgroup = taskgroup = TaskGroup()
|
||||
assert not self.interface and not self.interfaces
|
||||
assert not self._connecting_ifaces
|
||||
assert not self._closing_ifaces
|
||||
|
||||
@@ -1226,15 +1226,6 @@ def make_aiohttp_session(proxy: Optional[dict], headers=None, timeout=None):
|
||||
return aiohttp.ClientSession(headers=headers, timeout=timeout, connector=connector)
|
||||
|
||||
|
||||
class SilentTaskGroup(TaskGroup):
|
||||
|
||||
def spawn(self, *args, **kwargs):
|
||||
# don't complain if group is already closed.
|
||||
if self._closed:
|
||||
raise asyncio.CancelledError()
|
||||
return super().spawn(*args, **kwargs)
|
||||
|
||||
|
||||
class NetworkJobOnDefaultServer(Logger, ABC):
|
||||
"""An abstract base class for a job that runs on the main network
|
||||
interface. Every time the main interface changes, the job is
|
||||
@@ -1260,7 +1251,7 @@ class NetworkJobOnDefaultServer(Logger, ABC):
|
||||
"""Initialise fields. Called every time the underlying
|
||||
server connection changes.
|
||||
"""
|
||||
self.taskgroup = SilentTaskGroup()
|
||||
self.taskgroup = TaskGroup()
|
||||
|
||||
async def _start(self, interface: 'Interface'):
|
||||
self.interface = interface
|
||||
|
||||
Reference in New Issue
Block a user