server: don't crash after single exception

This commit is contained in:
Roman Zeyde
2016-01-08 20:46:49 +02:00
parent fb0d0a5f61
commit 33a6951a96
2 changed files with 6 additions and 2 deletions

View File

@@ -46,6 +46,8 @@ def handle_connection(conn, handler):
util.send(conn, reply)
except EOFError:
log.debug('goodbye agent')
except Exception as e: # pylint: disable=broad-except
log.warning('error: %s', e, exc_info=True)
def retry(func, exception_type, quit_event):

View File

@@ -4,6 +4,7 @@ import threading
import os
import io
import pytest
import mock
from .. import server
from .. import protocol
@@ -48,8 +49,9 @@ def test_handle():
server.handle_connection(conn, handler)
assert conn.tx.getvalue() == b'\x00\x00\x00\x05\x0C\x00\x00\x00\x00'
with pytest.raises(AttributeError):
server.handle_connection(conn=None, handler=None)
conn_mock = mock.Mock(spec=FakeSocket)
conn_mock.recv.side_effect = [Exception, EOFError]
server.handle_connection(conn=conn_mock, handler=None)
def test_server_thread():