Close the socket. Calling this method a second time does nothing, but if the file descriptor was closed elsewhere, :class:`OSError` will be raised.
(self)
| 66 | self.use_poll = use_poll |
| 67 | |
| 68 | def close(self): |
| 69 | """Close the socket. |
| 70 | |
| 71 | Calling this method a second time does nothing, but if the file |
| 72 | descriptor was closed elsewhere, :class:`OSError` will be raised. |
| 73 | """ |
| 74 | if self.child_fd == -1: |
| 75 | return |
| 76 | |
| 77 | self.flush() |
| 78 | self.socket.shutdown(socket.SHUT_RDWR) |
| 79 | self.socket.close() |
| 80 | self.child_fd = -1 |
| 81 | self.closed = True |
| 82 | |
| 83 | def isalive(self): |
| 84 | """ Alive if the fileno is valid """ |