Skip to content

Commit

Permalink
fix for issue 391 and issue 307
Browse files Browse the repository at this point in the history
  • Loading branch information
Qi Fan committed Oct 16, 2013
1 parent 471fbb8 commit 6e1d295
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pika/adapters/base_connection.py
Expand Up @@ -119,6 +119,8 @@ def _adapter_connect(self):

def _adapter_disconnect(self):
"""Invoked if the connection is being told to disconnect"""
if hasattr(self, 'heartbeat') and self.heartbeat is not None:
self.heartbeat.stop()
if self.socket:
self.socket.close()
self.socket = None
Expand Down Expand Up @@ -306,6 +308,11 @@ def _handle_events(self, fd, events, error=None, write_only=False):
if not write_only and (events & self.READ):
self._handle_read()

if write_only and (events & self.READ) and (events & self.ERROR):
LOGGER.error('BAD libc: Write-Only but Read+Error. '
'Assume socket disconnected.')
self._handle_disconnect()

if events & self.ERROR:
LOGGER.error('Error event %r, %r', events, error)
self._handle_error(error)
Expand Down

0 comments on commit 6e1d295

Please sign in to comment.