Skip to content

Commit

Permalink
Merge pull request #450 from jamutton/master
Browse files Browse the repository at this point in the history
PR340 made parent and child class methods identical
  • Loading branch information
gmr committed Apr 12, 2014
2 parents e47b4a6 + e7676e6 commit 3ad0fbe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions pika/adapters/base_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ def _handle_error(self, error_value):
else:
LOGGER.error("SSL Socket error on fd %d: %r",
self.socket.fileno(), error_value)
elif error_code == errno.EPIPE:
# Broken pipe, happens when connection reset
LOGGER.error("Socket connection was broken")
else:
# Haven't run into this one yet, log it.
LOGGER.error("Socket Error on fd %d: %s",
Expand Down
14 changes: 9 additions & 5 deletions pika/adapters/blocking_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,6 @@ def _deadline_passed(self, timeout_id):
return False
return self._timeouts[timeout_id]['deadline'] <= time.time()

def _handle_disconnect(self):
"""Called internally when the socket is disconnected already"""
self._adapter_disconnect()
self._on_connection_closed(None, True)

def _handle_read(self):
"""If the ReadPoller says there is data to read, try adn read it in the
_handle_read of the parent class. Once read, reset the counter that
Expand All @@ -366,6 +361,15 @@ def _handle_timeout(self):
LOGGER.critical('Closing connection due to timeout')
self._on_connection_closed(None, True)

def _check_state_on_disconnect(self):
"""Checks closing corner cases to see why we were disconnected and if we should
raise exceptions for the anticipated exception types.
"""
super(BlockingConnection, self)._check_state_on_disconnect()
if self.is_open:
# already logged a warning in the base class, now fire an exception
raise exceptions.ConnectionClosed()

This comment has been minimized.

Copy link
@vitaly-krugl

vitaly-krugl Mar 23, 2015

Member

@gmr, this logic is confusing and perhaps a bug. If we raise ConnectionClosed when self.is_open is True, then who is going to change self.connection_state to reflect that the connection is no longer open? When ConnectionClosed is raised and leaves scope of the pika code, the user code would expect connection.is_open to evaluate to False. However, this code appears to prevent the right thing from happening.

CC @jamutton


def _flush_outbound(self):
"""Flush the outbound socket buffer."""
if self.outbound_buffer:
Expand Down

0 comments on commit 3ad0fbe

Please sign in to comment.