commit 9607854b67d3a8a59b569c904c85466fbb34a8bc
parent 62e352a2a8e61ae930b6a09b1457d5419afea35c
Author: SomberNight <somber.night@protonmail.com>
Date: Mon, 10 Dec 2018 08:03:42 +0100
network: fix switching interface (restart old one)
follow-up b3ff173b4507e8325c65d607a4547320ba2c8798
connection_down was killing the already restarted old interface
Diffstat:
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/electrum/interface.py b/electrum/interface.py
@@ -253,7 +253,7 @@ class Interface(PrintError):
except GracefulDisconnect as e:
self.print_error("disconnecting gracefully. {}".format(e))
finally:
- await self.network.connection_down(self.server)
+ await self.network.connection_down(self)
self.got_disconnected.set_result(1)
return wrapper_func
diff --git a/electrum/network.py b/electrum/network.py
@@ -638,16 +638,16 @@ class Network(PrintError):
self.recent_servers = self.recent_servers[0:20]
self._save_recent_servers()
- async def connection_down(self, server):
+ async def connection_down(self, interface: Interface):
'''A connection to server either went down, or was never made.
We distinguish by whether it is in self.interfaces.'''
+ if not interface: return
+ server = interface.server
self.disconnected_servers.add(server)
if server == self.default_server:
self._set_status('disconnected')
- interface = self.interfaces.get(server, None)
- if interface:
- await self._close_interface(interface)
- self.trigger_callback('network_updated')
+ await self._close_interface(interface)
+ self.trigger_callback('network_updated')
@ignore_exceptions # do not kill main_taskgroup
@log_exceptions