From d915a2aaed6da541f69f3b5097bf755f4e42ff2a Mon Sep 17 00:00:00 2001 From: Kevin F Date: Sat, 17 Sep 2022 01:24:11 -0500 Subject: [PATCH] handle unix peer socket file not existing --- static-data/default-plugins/unixtransport/unixpeer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/static-data/default-plugins/unixtransport/unixpeer.py b/static-data/default-plugins/unixtransport/unixpeer.py index 2a788c61..faf8bdcf 100644 --- a/static-data/default-plugins/unixtransport/unixpeer.py +++ b/static-data/default-plugins/unixtransport/unixpeer.py @@ -1,6 +1,8 @@ from os.path import exists from socket import AF_UNIX, SOCK_STREAM, socket +from gossip.peerset import gossip_peer_set + class UnixPeer: def __init__(self, socket_file): @@ -14,8 +16,12 @@ class UnixPeer: def get_socket(self, connect_timeout) -> socket: s = socket(AF_UNIX, SOCK_STREAM) #s.settimeout(connect_timeout) - s.connect(self.transport_address) - return s + try: + s.connect(self.transport_address) + except FileNotFoundError: + gossip_peer_set.remove(self) + else: + return s def __hash__(self): return hash(self.transport_address)