Skip to content

Commit

Permalink
In BaseConnection.close, call _handle_ioloop_stop only if the connect…
Browse files Browse the repository at this point in the history
…ion is already closed to allow the asynchronous close operation to complete gracefully.
  • Loading branch information
Vitaly Kruglikov committed Jan 19, 2016
1 parent 3316392 commit d70da26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Next Release
- Connection failures that occur after the socket is opened and before the
AMQP connection is ready to go are now reported by calling the connection
error callback. Previously these were not consistently reported.
- In BaseConnection.close, call _handle_ioloop_stop only if the connection is
already closed to allow the asynchronous close operation to complete
gracefully.

0.10.0 2015-09-02
-----------------
Expand Down
7 changes: 5 additions & 2 deletions pika/adapters/base_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ def close(self, reply_code=200, reply_text='Normal shutdown'):
:param str reply_text: The text reason for the close
"""
super(BaseConnection, self).close(reply_code, reply_text)
self._handle_ioloop_stop()
try:
super(BaseConnection, self).close(reply_code, reply_text)
finally:
if self.is_closed:
self._handle_ioloop_stop()

def remove_timeout(self, timeout_id):
"""Remove the timeout from the IOLoop by the ID returned from
Expand Down

0 comments on commit d70da26

Please sign in to comment.