Skip to content

Commit 4887fb3

Browse files
committed
util.with_lock: add support for chaining with @event_listener
Consider e.g.: ``` class AddressSynchronizer(Logger, EventListener): [... snip ...] @event_listener @with_lock def on_event_blockchain_updated(self, *args): self._get_balance_cache = {} # invalidate cache self.db.put('stored_height', self.get_local_height()) ``` was raising: ``` func.__qualname__='with_lock.<locals>.func_wrapper' Traceback (most recent call last): File "...\electrum\run_electrum", line 105, in <module> from electrum.logging import get_logger, configure_logging # import logging submodule first File "...\electrum\electrum\__init__.py", line 19, in <module> from .wallet import Wallet File "...\electrum\electrum\wallet.py", line 70, in <module> from .address_synchronizer import ( File "...\electrum\electrum\address_synchronizer.py", line 75, in <module> class AddressSynchronizer(Logger, EventListener): File "...\electrum\electrum\address_synchronizer.py", line 205, in AddressSynchronizer def on_event_blockchain_updated(self, *args): File "...\electrum\electrum\util.py", line 2005, in event_listener classname, method_name = func.__qualname__.split('.') ValueError: too many values to unpack (expected 2) ```
1 parent 051b7eb commit 4887fb3

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

electrum/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ async def wrapper(*args, **kwargs):
12431243

12441244
def with_lock(func):
12451245
"""Decorator to enforce a lock on a function call."""
1246+
@functools.wraps(func)
12461247
def func_wrapper(self, *args, **kwargs):
12471248
with self.lock:
12481249
return func(self, *args, **kwargs)

0 commit comments

Comments
 (0)