Skip to content

Commit 2819402

Browse files
SNOW-2176524 reapply closed socket detection patch
1 parent e9b3b2d commit 2819402

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/snowflake/connector/vendored/urllib3/connection.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,22 @@ def connect(self) -> None:
338338
if self._has_connected_to_proxy:
339339
self.proxy_is_verified = False
340340

341+
# See issue for more context: https://github.com/urllib3/urllib3/issues/1878
342+
# the maintainers know that this issue can be resolve using the change below but
343+
# they have not merged this change because they need to root-cause it. See
344+
# comment: https://github.com/urllib3/urllib3/issues/1878#issuecomment-641548977
345+
# adding the fix in our vendored code so our users get unblocked
346+
def _is_closed_patch_for_invalid_socket_descriptor(self):
347+
if getattr(self.sock, "fileno", lambda _: None)() == -1:
348+
return True
349+
341350
@property
342351
def is_closed(self) -> bool:
343-
return self.sock is None
352+
return self.sock is None or self._is_closed_patch_for_invalid_socket_descriptor()
344353

345354
@property
346355
def is_connected(self) -> bool:
347-
if self.sock is None:
356+
if self.sock is None or self._is_closed_patch_for_invalid_socket_descriptor():
348357
return False
349358
return not wait_for_read(self.sock, timeout=0.0)
350359

0 commit comments

Comments
 (0)