MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / socket_closed

Method socket_closed

pymongo/socket_checker.py:84–102  ·  view source on GitHub ↗

Return True if we know socket has been closed, False otherwise.

(self, sock: Any)

Source from the content-addressed store, hash-verified

82 raise
83
84 def socket_closed(self, sock: Any) -> bool:
85 """Return True if we know socket has been closed, False otherwise."""
86 try:
87 return self.select(sock, read=True)
88 except (RuntimeError, KeyError):
89 # RuntimeError is raised during a concurrent poll. KeyError
90 # is raised by unregister if the socket is not in the poller.
91 # These errors should not be possible since we protect the
92 # poller with a mutex.
93 raise
94 except ValueError:
95 # ValueError is raised by register/unregister/select if the
96 # socket file descriptor is negative or outside the range for
97 # select (> 1023).
98 return True
99 except Exception:
100 # Any other exceptions should be attributed to a closed
101 # or invalid socket.
102 return True

Callers 6

test_socket_closedMethod · 0.95
test_socket_checkerMethod · 0.95
test_socket_closedMethod · 0.95
test_socket_checkerMethod · 0.95
conn_closedMethod · 0.80
conn_closedMethod · 0.80

Calls 1

selectMethod · 0.95

Tested by 4

test_socket_closedMethod · 0.76
test_socket_checkerMethod · 0.76
test_socket_closedMethod · 0.76
test_socket_checkerMethod · 0.76