@@ -179,6 +179,40 @@ async def test_async_task_ok(comm):
179179 await task
180180
181181
182+ @pytest .mark .xdist_group (name = "server_serialize" )
183+ @pytest .mark .parametrize ("comm" , TEST_TYPES )
184+ async def test_async_task_reuse (comm ):
185+ """Test normal client/server handling."""
186+ run_server , server_args , run_client , client_args = helper_config (comm , "async" )
187+
188+ task = asyncio .create_task (run_server (** server_args ))
189+ await asyncio .sleep (0.1 )
190+ client = run_client (** client_args )
191+ await client .connect ()
192+ await asyncio .sleep (0.1 )
193+ assert client ._connected # pylint: disable=protected-access
194+ rr = await client .read_coils (1 , 1 , slave = 0x01 )
195+ assert len (rr .bits ) == 8
196+
197+ await client .close ()
198+ await asyncio .sleep (0.1 )
199+ assert not client ._connected # pylint: disable=protected-access
200+
201+ await client .connect ()
202+ await asyncio .sleep (0.1 )
203+ assert client ._connected # pylint: disable=protected-access
204+ rr = await client .read_coils (1 , 1 , slave = 0x01 )
205+ assert len (rr .bits ) == 8
206+
207+ await client .close ()
208+ await asyncio .sleep (0.1 )
209+ assert not client ._connected # pylint: disable=protected-access
210+
211+ await server .ServerAsyncStop ()
212+ task .cancel ()
213+ await task
214+
215+
182216@pytest .mark .xdist_group (name = "server_serialize" )
183217@pytest .mark .parametrize ("comm" , TEST_TYPES )
184218async def test_async_task_server_stop (comm ):
0 commit comments