Skip to content

Commit

Permalink
End control server response with newline
Browse files Browse the repository at this point in the history
  • Loading branch information
daniil-berg committed May 7, 2022
1 parent 28c997e commit ee0b8c0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Daniil Fajnberg'

# The full version, including alpha/beta/rc tags
release = '1.1.2'
release = '1.1.3'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = asyncio-taskpool
version = 1.1.2
version = 1.1.3
author = Daniil Fajnberg
author_email = [email protected]
description = Dynamically manage pools of asyncio tasks
Expand Down
2 changes: 2 additions & 0 deletions src/asyncio_taskpool/control/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ async def client_handshake(self) -> None:
metavar="(A command followed by '-h' or '--help' will show command-specific help.)")
self._parser.add_class_commands(self._pool.__class__)
self._writer.write(str(self._pool).encode())
self._writer.write(b'\n')
await self._writer.drain()

async def _parse_command(self, msg: str) -> None:
Expand Down Expand Up @@ -197,4 +198,5 @@ async def listen(self) -> None:
self._response_buffer.seek(0)
self._response_buffer.truncate()
self._writer.write(response.encode())
self._writer.write(b'\n')
await self._writer.drain()
4 changes: 2 additions & 2 deletions tests/test_control/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def test_client_handshake(self, mock_parser_cls: MagicMock):
mock_parser_cls.assert_called_once_with(**expected_parser_kwargs)
mock_add_subparsers.assert_called_once_with(**expected_subparsers_kwargs)
mock_add_class_commands.assert_called_once_with(self.mock_pool.__class__)
self.mock_writer.write.assert_called_once_with(str(self.mock_pool).encode())
self.mock_writer.write.assert_has_calls([call(str(self.mock_pool).encode()), call(b'\n')])
self.mock_writer.drain.assert_awaited_once_with()

@patch.object(session.ControlSession, '_exec_property_and_respond')
Expand Down Expand Up @@ -200,7 +200,7 @@ def make_reader_return_empty():
self.mock_reader.readline.assert_has_awaits([call(), call()])
mock__parse_command.assert_awaited_once_with(msg)
self.assertEqual('', self.session._response_buffer.getvalue())
self.mock_writer.write.assert_called_once_with(response.encode())
self.mock_writer.write.assert_has_calls([call(response.encode()), call(b'\n')])
self.mock_writer.drain.assert_awaited_once_with()

self.mock_reader.readline.reset_mock()
Expand Down

0 comments on commit ee0b8c0

Please sign in to comment.