Closes the event streaming.
(self)
| 35 | next = __next__ |
| 36 | |
| 37 | def close(self): |
| 38 | """ |
| 39 | Closes the event streaming. |
| 40 | """ |
| 41 | |
| 42 | if not self._response.raw.closed: |
| 43 | # find the underlying socket object |
| 44 | # based on api.client._get_raw_response_socket |
| 45 | |
| 46 | sock_fp = self._response.raw._fp.fp |
| 47 | |
| 48 | if hasattr(sock_fp, 'raw'): |
| 49 | sock_raw = sock_fp.raw |
| 50 | |
| 51 | if hasattr(sock_raw, 'sock'): |
| 52 | sock = sock_raw.sock |
| 53 | |
| 54 | elif hasattr(sock_raw, '_sock'): |
| 55 | sock = sock_raw._sock |
| 56 | |
| 57 | elif hasattr(sock_fp, 'channel'): |
| 58 | # We're working with a paramiko (SSH) channel, which doesn't |
| 59 | # support cancelable streams with the current implementation |
| 60 | raise DockerException( |
| 61 | 'Cancellable streams not supported for the SSH protocol' |
| 62 | ) |
| 63 | else: |
| 64 | sock = sock_fp._sock |
| 65 | |
| 66 | if hasattr(urllib3.contrib, 'pyopenssl') and isinstance( |
| 67 | sock, urllib3.contrib.pyopenssl.WrappedSocket): |
| 68 | sock = sock.socket |
| 69 | |
| 70 | sock.shutdown(socket.SHUT_RDWR) |
| 71 | sock.close() |
nothing calls this directly
no test coverage detected