diff options
author | Dana Powers <dana.powers@gmail.com> | 2016-08-03 16:31:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-03 16:31:38 -0700 |
commit | 0e753e659280e278b06b26d0cdbf8b184e73de58 (patch) | |
tree | dbbce502914241ccdc1c58ea8e40c8e70a661cca /kafka/client_async.py | |
parent | 709ee3b59aff8ab205f0e09c33f4ec8391664228 (diff) | |
download | kafka-python-0e753e659280e278b06b26d0cdbf8b184e73de58.tar.gz |
Ignore socket.error when checking for protocol out of sync prior to socket close (#792)
Diffstat (limited to 'kafka/client_async.py')
-rw-r--r-- | kafka/client_async.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/kafka/client_async.py b/kafka/client_async.py index 6e07ab0..127b3f5 100644 --- a/kafka/client_async.py +++ b/kafka/client_async.py @@ -537,10 +537,13 @@ class KafkaClient(object): # # either way, we can no longer safely use this connection # - # Do a 1-byte read to clear the READ flag, and then close the conn - unexpected_data = key.fileobj.recv(1) - if unexpected_data: # anything other than a 0-byte read means protocol issues - log.warning('Protocol out of sync on %r, closing', conn) + # Do a 1-byte read to check protocol didnt get out of sync, and then close the conn + try: + unexpected_data = key.fileobj.recv(1) + if unexpected_data: # anything other than a 0-byte read means protocol issues + log.warning('Protocol out of sync on %r, closing', conn) + except socket.error: + pass conn.close() continue |