|
36 | 36 |
|
37 | 37 | if six.PY2:
|
38 | 38 | ConnectionError = socket.error
|
| 39 | + TimeoutError = socket.error |
39 | 40 | BlockingIOError = Exception
|
40 | 41 |
|
41 | 42 | log = logging.getLogger(__name__)
|
@@ -498,7 +499,7 @@ def _try_handshake(self):
|
498 | 499 | # old ssl in python2.6 will swallow all SSLErrors here...
|
499 | 500 | except (SSLWantReadError, SSLWantWriteError):
|
500 | 501 | pass
|
501 |
| - except (SSLZeroReturnError, ConnectionError, SSLEOFError): |
| 502 | + except (SSLZeroReturnError, ConnectionError, TimeoutError, SSLEOFError): |
502 | 503 | log.warning('SSL connection closed by server during handshake.')
|
503 | 504 | self.close(Errors.KafkaConnectionError('SSL connection closed by server during handshake'))
|
504 | 505 | # Other SSLErrors will be raised to user
|
@@ -599,7 +600,7 @@ def _try_authenticate_plain(self, future):
|
599 | 600 | # The connection is closed on failure
|
600 | 601 | data = self._recv_bytes_blocking(4)
|
601 | 602 |
|
602 |
| - except ConnectionError as e: |
| 603 | + except (ConnectionError, TimeoutError) as e: |
603 | 604 | log.exception("%s: Error receiving reply from server", self)
|
604 | 605 | error = Errors.KafkaConnectionError("%s: %s" % (self, e))
|
605 | 606 | self.close(error=error)
|
@@ -665,7 +666,7 @@ def _try_authenticate_gssapi(self, future):
|
665 | 666 | size = Int32.encode(len(msg))
|
666 | 667 | self._send_bytes_blocking(size + msg)
|
667 | 668 |
|
668 |
| - except ConnectionError as e: |
| 669 | + except (ConnectionError, TimeoutError) as e: |
669 | 670 | self._lock.release()
|
670 | 671 | log.exception("%s: Error receiving reply from server", self)
|
671 | 672 | error = Errors.KafkaConnectionError("%s: %s" % (self, e))
|
@@ -695,7 +696,7 @@ def _try_authenticate_oauth(self, future):
|
695 | 696 | # The connection is closed on failure
|
696 | 697 | data = self._recv_bytes_blocking(4)
|
697 | 698 |
|
698 |
| - except ConnectionError as e: |
| 699 | + except (ConnectionError, TimeoutError) as e: |
699 | 700 | self._lock.release()
|
700 | 701 | log.exception("%s: Error receiving reply from server", self)
|
701 | 702 | error = Errors.KafkaConnectionError("%s: %s" % (self, e))
|
@@ -886,7 +887,7 @@ def send_pending_requests(self):
|
886 | 887 | if self._sensors:
|
887 | 888 | self._sensors.bytes_sent.record(total_bytes)
|
888 | 889 | return total_bytes
|
889 |
| - except ConnectionError as e: |
| 890 | + except (ConnectionError, TimeoutError) as e: |
890 | 891 | log.exception("Error sending request data to %s", self)
|
891 | 892 | error = Errors.KafkaConnectionError("%s: %s" % (self, e))
|
892 | 893 | self.close(error=error)
|
@@ -954,7 +955,7 @@ def _recv(self):
|
954 | 955 |
|
955 | 956 | except SSLWantReadError:
|
956 | 957 | break
|
957 |
| - except ConnectionError as e: |
| 958 | + except (ConnectionError, TimeoutError) as e: |
958 | 959 | if six.PY2 and e.errno == errno.EWOULDBLOCK:
|
959 | 960 | break
|
960 | 961 | log.exception('%s: Error receiving network data'
|
|
0 commit comments