use functools.wraps() for some wrappers
to help debugging
This commit is contained in:
@@ -35,6 +35,7 @@ from ipaddress import IPv4Network, IPv6Network, ip_address, IPv6Address, IPv4Add
|
|||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import functools
|
||||||
|
|
||||||
import aiorpcx
|
import aiorpcx
|
||||||
from aiorpcx import TaskGroup
|
from aiorpcx import TaskGroup
|
||||||
@@ -375,10 +376,13 @@ class Interface(Logger):
|
|||||||
# Dump network messages (only for this interface). Set at runtime from the console.
|
# Dump network messages (only for this interface). Set at runtime from the console.
|
||||||
self.debug = False
|
self.debug = False
|
||||||
|
|
||||||
asyncio.run_coroutine_threadsafe(
|
|
||||||
self.network.taskgroup.spawn(self.run()), self.network.asyncio_loop)
|
|
||||||
self.taskgroup = SilentTaskGroup()
|
self.taskgroup = SilentTaskGroup()
|
||||||
|
|
||||||
|
async def spawn_task():
|
||||||
|
task = await self.network.taskgroup.spawn(self.run())
|
||||||
|
task.set_name(f"interface::{str(server)}")
|
||||||
|
asyncio.run_coroutine_threadsafe(spawn_task(), self.network.asyncio_loop)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host(self):
|
def host(self):
|
||||||
return self.server.host
|
return self.server.host
|
||||||
@@ -476,6 +480,7 @@ class Interface(Logger):
|
|||||||
return sslc
|
return sslc
|
||||||
|
|
||||||
def handle_disconnect(func):
|
def handle_disconnect(func):
|
||||||
|
@functools.wraps(func)
|
||||||
async def wrapper_func(self: 'Interface', *args, **kwargs):
|
async def wrapper_func(self: 'Interface', *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return await func(self, *args, **kwargs)
|
return await func(self, *args, **kwargs)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
from typing import Tuple, Dict, TYPE_CHECKING, Optional, Union
|
from typing import Tuple, Dict, TYPE_CHECKING, Optional, Union
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import functools
|
||||||
|
|
||||||
import aiorpcx
|
import aiorpcx
|
||||||
|
|
||||||
@@ -289,6 +290,7 @@ class Peer(Logger):
|
|||||||
self.announcement_signatures[chan.channel_id].put_nowait(payload)
|
self.announcement_signatures[chan.channel_id].put_nowait(payload)
|
||||||
|
|
||||||
def handle_disconnect(func):
|
def handle_disconnect(func):
|
||||||
|
@functools.wraps(func)
|
||||||
async def wrapper_func(self, *args, **kwargs):
|
async def wrapper_func(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return await func(self, *args, **kwargs)
|
return await func(self, *args, **kwargs)
|
||||||
@@ -550,6 +552,7 @@ class Peer(Logger):
|
|||||||
# During the channel open flow, if we initiated, we might have used a change address
|
# During the channel open flow, if we initiated, we might have used a change address
|
||||||
# of ours in the funding tx. The funding tx is not part of the wallet history
|
# of ours in the funding tx. The funding tx is not part of the wallet history
|
||||||
# at that point yet, but we should already consider this change address as 'used'.
|
# at that point yet, but we should already consider this change address as 'used'.
|
||||||
|
@functools.wraps(func)
|
||||||
async def wrapper(self: 'Peer', *args, **kwargs):
|
async def wrapper(self: 'Peer', *args, **kwargs):
|
||||||
funding_tx = kwargs['funding_tx'] # type: PartialTransaction
|
funding_tx = kwargs['funding_tx'] # type: PartialTransaction
|
||||||
wallet = self.lnworker.wallet
|
wallet = self.lnworker.wallet
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import ipaddress
|
|||||||
from ipaddress import IPv4Address, IPv6Address
|
from ipaddress import IPv4Address, IPv6Address
|
||||||
import random
|
import random
|
||||||
import secrets
|
import secrets
|
||||||
|
import functools
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@@ -1086,6 +1087,7 @@ def make_dir(path, allow_symlink=True):
|
|||||||
def log_exceptions(func):
|
def log_exceptions(func):
|
||||||
"""Decorator to log AND re-raise exceptions."""
|
"""Decorator to log AND re-raise exceptions."""
|
||||||
assert asyncio.iscoroutinefunction(func), 'func needs to be a coroutine'
|
assert asyncio.iscoroutinefunction(func), 'func needs to be a coroutine'
|
||||||
|
@functools.wraps(func)
|
||||||
async def wrapper(*args, **kwargs):
|
async def wrapper(*args, **kwargs):
|
||||||
self = args[0] if len(args) > 0 else None
|
self = args[0] if len(args) > 0 else None
|
||||||
try:
|
try:
|
||||||
@@ -1105,6 +1107,7 @@ def log_exceptions(func):
|
|||||||
def ignore_exceptions(func):
|
def ignore_exceptions(func):
|
||||||
"""Decorator to silently swallow all exceptions."""
|
"""Decorator to silently swallow all exceptions."""
|
||||||
assert asyncio.iscoroutinefunction(func), 'func needs to be a coroutine'
|
assert asyncio.iscoroutinefunction(func), 'func needs to be a coroutine'
|
||||||
|
@functools.wraps(func)
|
||||||
async def wrapper(*args, **kwargs):
|
async def wrapper(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return await func(*args, **kwargs)
|
return await func(*args, **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user