Merge pull request #1765 from kingosticks/fix/close-connection-on-failure
Close MPD connection following an exception in handler.
This commit is contained in:
commit
49a08f1701
@ -9,6 +9,15 @@ This changelog is used to track all major changes to Mopidy.
|
||||
For older releases, see :ref:`history`.
|
||||
|
||||
|
||||
v2.2.4 (UNRELEASED)
|
||||
===================
|
||||
|
||||
Bug fix release.
|
||||
|
||||
- Network: Close connection following an exception in the protocol handler.
|
||||
(Fixes: :issue:`1762`, PR: :issue:`1765`)
|
||||
|
||||
|
||||
v2.2.3 (2019-06-20)
|
||||
===================
|
||||
|
||||
|
||||
@ -425,8 +425,12 @@ class LineProtocol(pykka.ThreadingActor):
|
||||
if not self.prevent_timeout:
|
||||
self.connection.enable_timeout()
|
||||
|
||||
def on_failure(self, exception_type, exception_value, traceback):
|
||||
"""Clean up connection resouces when actor fails."""
|
||||
self.connection.stop('Actor failed.')
|
||||
|
||||
def on_stop(self):
|
||||
"""Ensure that cleanup when actor stops."""
|
||||
"""Clean up connection resouces when actor stops."""
|
||||
self.connection.stop('Actor is shutting down.')
|
||||
|
||||
def parse_lines(self):
|
||||
|
||||
@ -121,6 +121,12 @@ class LineProtocolTest(unittest.TestCase):
|
||||
self.mock, {'received': 'line1\nline2\n'})
|
||||
self.assertEqual(2, self.mock.on_line_received.call_count)
|
||||
|
||||
def test_on_failure_calls_stop(self):
|
||||
self.mock.connection = Mock(spec=network.Connection)
|
||||
|
||||
network.LineProtocol.on_failure(self.mock, None, None, None)
|
||||
self.mock.connection.stop.assert_called_once_with('Actor failed.')
|
||||
|
||||
def test_parse_lines_emtpy_buffer(self):
|
||||
self.mock.delimiter = re.compile(r'\n')
|
||||
self.mock.recv_buffer = ''
|
||||
|
||||
Loading…
Reference in New Issue
Block a user