Return True if we know socket has been closed, False otherwise.
(self, sock: Any)
| 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 |