server: don't crash after single exception

nistp521
Roman Zeyde 9 years ago
parent fb0d0a5f61
commit 33a6951a96

@ -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):

@ -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():

Loading…
Cancel
Save