Skip to content

Commit dad5bb1

Browse files
author
James William Pye
committed
Don't [ssl] try-again if a socket error was the cause of the connection failure.
1 parent 8569aa1 commit dad5bb1

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

postgresql/driver/pq3.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,17 @@ def connect(self, timeout = None):
21502150
# *not* be ran because it has already been noted to be
21512151
# a failure.
21522152
can_skip = True
2153+
# If the exception is a socket error, chances are that it's
2154+
# going to fail again.
2155+
if isinstance(e, self.connector.fatal_exception):
2156+
if sslmode == 'prefer' and dossl is True:
2157+
# when 'prefer', the first attempt
2158+
# is marked with dossl is True
2159+
can_skip = True
2160+
elif sslmode == 'allow' and dossl is False:
2161+
# when 'allow', the first attempt
2162+
# is marked with dossl is False
2163+
can_skip = True
21532164
if self.socket is not None:
21542165
self.socket.close()
21552166
self.socket = None

0 commit comments

Comments
 (0)