Skip to content

Commit

Permalink
eliminate redundant server_close() (#2041)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 authored Feb 21, 2024
1 parent f44507c commit c0a782d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
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

0 comments on commit c0a782d

Please sign in to comment.