handle unix peer socket file not existing
This commit is contained in:
parent
25e705c0b2
commit
d915a2aaed
@ -1,6 +1,8 @@
|
|||||||
from os.path import exists
|
from os.path import exists
|
||||||
from socket import AF_UNIX, SOCK_STREAM, socket
|
from socket import AF_UNIX, SOCK_STREAM, socket
|
||||||
|
|
||||||
|
from gossip.peerset import gossip_peer_set
|
||||||
|
|
||||||
class UnixPeer:
|
class UnixPeer:
|
||||||
|
|
||||||
def __init__(self, socket_file):
|
def __init__(self, socket_file):
|
||||||
@ -14,8 +16,12 @@ class UnixPeer:
|
|||||||
def get_socket(self, connect_timeout) -> socket:
|
def get_socket(self, connect_timeout) -> socket:
|
||||||
s = socket(AF_UNIX, SOCK_STREAM)
|
s = socket(AF_UNIX, SOCK_STREAM)
|
||||||
#s.settimeout(connect_timeout)
|
#s.settimeout(connect_timeout)
|
||||||
s.connect(self.transport_address)
|
try:
|
||||||
return s
|
s.connect(self.transport_address)
|
||||||
|
except FileNotFoundError:
|
||||||
|
gossip_peer_set.remove(self)
|
||||||
|
else:
|
||||||
|
return s
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(self.transport_address)
|
return hash(self.transport_address)
|
||||||
|
Loading…
Reference in New Issue
Block a user