diff --git a/electrum/plugins/nwc/nwcserver.py b/electrum/plugins/nwc/nwcserver.py index 7823b3380..112859ccf 100644 --- a/electrum/plugins/nwc/nwcserver.py +++ b/electrum/plugins/nwc/nwcserver.py @@ -39,7 +39,7 @@ from electrum.plugin import BasePlugin, hook from electrum.logging import Logger from electrum.util import log_exceptions, ca_path, OldTaskGroup, get_asyncio_loop, InvoiceError, \ LightningHistoryItem, event_listener, EventListener, make_aiohttp_proxy_connector, \ - get_running_loop + get_running_loop, run_sync_function_on_asyncio_thread from electrum.invoices import Invoice, Request, PR_UNKNOWN, PR_PAID, BaseInvoice, PR_INFLIGHT from electrum import constants from electrum.lnutil import RECEIVED @@ -278,7 +278,7 @@ class NWCServer(Logger, EventListener): def restart_event_handler(self) -> None: """To be called when the connections change so we restart with a new filter""" if self.event_handler_task: - self.event_handler_task.cancel() + run_sync_function_on_asyncio_thread(self.event_handler_task.cancel, block=True) @event_listener def on_event_proxy_set(self, *args):