code: def coro(f):
      
      f = asyncio.coroutine(f)
  
      def wrapper(*args, **kwargs):
          loop = asyncio.get_event_loop()
          try:
              return loop.run_until_complete(f(*args, **kwargs))
          except KeyboardInterrupt:
              click.echo("Got CTRL+C, quitting..")
              dev = args[0]
              loop.run_until_complete(dev.stop_listen_notifications())
          except SongpalException as ex:
              err("Error: %s" % ex)
              if len(args) > 0 and hasattr(args[0], "debug"):
                  if args[0].debug > 0:
                      raise ex
  
      return update_wrapper(wrapper, f)
docs: Run a coroutine and handle possible errors for the click cli.
  
      Source https://github.com/pallets/click/issues/85#issuecomment-43378930