import asyncio async def send_update_command(): while True: command = "update_position_command\n" print('command') await asyncio.sleep(2) #await writer.drain() await asyncio.sleep(1) async def query_robot_status(): while True: command = "query_status_command\n" print('status') await asyncio.sleep(1) # await writer.drain() #feedback = await reader.read(1024) #if feedback: # print("Received feedback:", feedback.decode()) await asyncio.sleep(2) async def main(): #reader, writer = await asyncio.open_connection('f', 'f') await asyncio.gather( send_update_command(), query_robot_status() ) print('UI') asyncio.run(main())