async def netgear_async_playback(pattern): try: # define and launch Client with `receive_mode = True` server = NetGear_Async(address = PeerAddress, port = PeerPort, logging=pattern.logging) # invalid protocol server.config["generator"] = custom_frame_generator(pattern) server.launch() # define and launch Client with `receive_mode = True` and timeout = 5.0 client = NetGear_Async(port = HostPort,receive_mode=True, timeout=float("inf"), logging=pattern.logging).launch() # gather and run tasks input_coroutines = [server.task, client_iterator(client, pattern)] res = await asyncio.gather(*input_coroutines, return_exceptions=True) except Exception as e: print(e) pass finally: try: server except Exception as e: print("server undefined") else: server.close(skip_loop=True) try: client except Exception as e: print("client undefined") else: client.close(skip_loop=True)
async def test_netgear_async_bidirectionalmode(generator, data, options_server, options_client, result): try: server = NetGear_Async(logging=True, timeout=5.0, **options_server) if not generator: cg = Custom_Generator(server, data=data) generator = cg.custom_dataframe_generator() server.config["generator"] = generator server.launch() # define and launch Client with `receive_mode = True` and timeout = 5.0 client = NetGear_Async(logging=True, receive_mode=True, timeout=5.0, **options_client).launch() # gather and run tasks input_coroutines = [ server.task, client_dataframe_iterator(client, data=data) ] res = await asyncio.gather(*input_coroutines, return_exceptions=True) except Exception as e: if result: pytest.fail(str(e)) else: pytest.xfail(str(e)) finally: server.close(skip_loop=True) client.close(skip_loop=True)
async def test_netgear_async_custom_server_generator(generator, result): try: server = NetGear_Async(protocol="udp", logging=True) # invalid protocol server.config["generator"] = generator server.launch() # define and launch Client with `receive_mode = True` and timeout = 5.0 client = NetGear_Async(logging=True, receive_mode=True, timeout=5.0).launch() # gather and run tasks input_coroutines = [server.task, client_iterator(client)] res = await asyncio.gather(*input_coroutines, return_exceptions=True) except Exception as e: if result: pytest.fail(str(e)) finally: if result: server.close(skip_loop=True) client.close(skip_loop=True)