Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eliminate redundant server_close() #2041

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions pymodbus/server/async_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,6 @@ def callback_new_connection(self):
return ModbusServerRequestHandler(self)

async def shutdown(self):
"""Shutdown server."""
await self.server_close()

async def server_close(self):
"""Close server."""
if not self.serving.done():
self.serving.set_result(True)
Expand Down
12 changes: 6 additions & 6 deletions test/sub_server/test_server_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def _setup_teardown(self):

# teardown
if self.server is not None:
await self.server.server_close()
await self.server.shutdown()
self.server = None
if self.task is not None:
await asyncio.sleep(0.1)
Expand Down Expand Up @@ -239,15 +239,15 @@ async def test_async_tcp_server_connection_lost(self):
BasicClient.transport.close()
await asyncio.sleep(0.2) # so we have to wait a bit

async def test_async_tcp_server_close_connection(self):
"""Test server_close() while there are active TCP connections."""
async def test_async_tcp_server_shutdown_connection(self):
"""Test server shutdown() while there are active TCP connections."""
await self.start_server()
await self.connect_server()

# On Windows we seem to need to give this an extra chance to finish,
# otherwise there ends up being an active connection at the assert.
await asyncio.sleep(0.5)
await self.server.server_close()
await self.server.shutdown()

async def test_async_tcp_server_no_slave(self):
"""Test unknown slave exception."""
Expand All @@ -258,7 +258,7 @@ async def test_async_tcp_server_no_slave(self):
await self.start_server()
await self.connect_server()
assert not BasicClient.eof.done()
await self.server.server_close()
await self.server.shutdown()
self.server = None

async def test_async_tcp_server_modbus_error(self):
Expand Down Expand Up @@ -313,7 +313,7 @@ async def test_async_start_udp_server(self):
async def test_async_udp_server_serve_forever_close(self):
"""Test StarAsyncUdpServer serve_forever() method."""
await self.start_server(do_udp=True)
await self.server.server_close()
await self.server.shutdown()
self.server = None

async def test_async_udp_server_serve_forever_twice(self):
Expand Down