text: from pprint import pprint
  import asyncio
  
  import yaml
  from scrapli import AsyncScrapli
  from scrapli.exceptions import ScrapliException
  
  
  # from ex04_scrapli_async_send_show_commands import send_show
  async def send_show(device, show_commands):
      cmd_dict = {}
      if type(show_commands) == str:
          show_commands = [show_commands]
      try:
          async with AsyncScrapli(**device) as ssh:
              for cmd in show_commands:
                  reply = await ssh.send_command(cmd)
                  cmd_dict[cmd] = reply.result
          return cmd_dict
      except ScrapliException as error:
          print(error, device["host"])
  
  
  async def send_command_to_devices(devices, commands):
      results = []
      coroutines = [send_show(device, commands) for device in devices]
      for coro in asyncio.as_completed(coroutines):
          results.append(await coro)
      return results
  
  
  if __name__ == "__main__":
      with open("devices_async.yaml") as f:
          devices = yaml.safe_load(f)
      result = asyncio.run(send_command_to_devices(devices, "sh ip int br"))
      pprint(result, width=120)
  