docs: def run(coro: 'Optional[Coroutine]' = None, *,
          loop: Optional[AbstractEventLoop] = None,
          shutdown_handler: Optional[Callable[[AbstractEventLoop], None]] = None,
          executor_workers: int = 10,
          executor: Optional[Executor] = None,
          use_uvloop: bool = False) -> None:
      """
      Start up the event loop, and wait for a signal to shut down.
  
      :param coro: Optionally supply a coroutine. The loop will still
          run if missing. The loop will continue to run after the supplied
          coroutine finishes. The supplied coroutine is typically
          a "main" coroutine from which all other work is spawned.
      :param loop: Optionally supply your own loop. If missing, the
          default loop attached to the current thread context will
          be used, i.e., whatever ``asyncio.get_event_loop()`` returns.
      :param shutdown_handler: By default, SIGINT and SIGTERM will be
          handled and will stop the loop, thereby invoking the shutdown
          sequence. Alternatively you can supply your own shutdown
          handler function. It should conform to the type spec as shown
          in the function signature.
      :param executor_workers: The number of workers in the executor.
          (NOTE: ``run()`` creates a new executor instance internally,
          regardless of whether you supply your own loop.)
      :param executor: You can decide to use your own executor instance
          if you like.
      :param use_uvloop: The loop policy will be set to use uvloop. It
          is your responsibility to install uvloop. If missing, an
          ``ImportError`` will be raised.
      """
      logger.debug('Entering run()')
  
      assert not (loop and use_uvloop), (
          "'loop' and 'use_uvloop' parameters are mutually "
          "exclusive. (Just make your own uvloop and pass it in)."
      )
      if use_uvloop:
          import uvloop
          asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
  
      loop_was_supplied = bool(loop)
      if not loop_was_supplied:
          loop = get_event_loop()
  
      if coro:
          async def new_coro():
              """During shutdown, run_until_complete() will exit
              if a CancelledError bubbles up from anything in the
              group. To counteract that, we'll try to handle
              any CancelledErrors that bubble up from the given
              coro. This isn't fool-proof: if the user doesn't
              provide a coro, and instead creates their own with
              loop.create_task, that task might bubble
              a CancelledError into the run_until_complete()."""
              try:
                  await coro
              except asyncio.CancelledError:
                  pass
          loop.create_task(new_coro())
  
      shutdown_handler = shutdown_handler or _shutdown_handler
  
      if WINDOWS:  # pragma: no cover
          # This is to allow CTRL-C to be detected in a timely fashion,
          # see: https://bugs.python.org/issue23057#msg246316
          loop.create_task(windows_support_wakeup())
  
          # This is to be able to handle SIGBREAK.
          def windows_handler(sig, frame):
              # Disable the handler so it won't be called again.
              signame = signal.Signals(sig).name
              logger.critical('Received signal: %s. Stopping the loop.', signame)
              shutdown_handler(loop)
  
          signal.signal(signal.SIGBREAK, windows_handler)
          signal.signal(signal.SIGINT, windows_handler)
      else:
          loop.add_signal_handler(SIGINT, shutdown_handler, loop)
          loop.add_signal_handler(SIGTERM, shutdown_handler, loop)
  
      # TODO: We probably don't want to create a different executor if the
      # TODO: loop was supplied. (User might have put stuff on that loop's
      # TODO: executor).
      if not executor:
          logger.debug('Creating default executor')
          executor = ThreadPoolExecutor(max_workers=executor_workers)
      loop.set_default_executor(executor)
      try:
          loop.run_forever()
      except KeyboardInterrupt:  # pragma: no cover
          logger.info('Got KeyboardInterrupt')
          if WINDOWS:
              # Windows doesn't do any POSIX signal handling, and no
              # abstraction layer for signals is currently implemented in
              # asyncio. So we fall back to KeyboardInterrupt (triggered
              # by the user/environment sending CTRL-C, or signal.CTRL_C_EVENT
              shutdown_handler()
      logger.info('Entering shutdown phase.')
  
      def sep():
          tasks = all_tasks(loop=loop)
          do_not_cancel = set()
          for t in tasks:
              # TODO: we don't need access to the coro. We could simply
              # TODO: store the task itself in the weakset.
              if t._coro in _DO_NOT_CANCEL_COROS:
                  do_not_cancel.add(t)
  
          tasks -= do_not_cancel
  
          logger.info('Cancelling pending tasks.')
          for t in tasks:
              logger.debug('Cancelling task: %s', t)
              t.cancel()
          return tasks, do_not_cancel
  
      tasks, do_not_cancel = sep()
      # Here's a protip: if you group a bunch of tasks, and some of them
      # get cancelled, and they DON'T HANDLE THE CANCELLATION, then the
      # raised CancelledError will bubble up to, and stop the
      # loop.run_until_complete() line: meaning, not all the tasks in
      # the gathered group will actually be complete. You need to
      # enable this with the ``return_exceptions`` flag.
      group = gather(*tasks, *do_not_cancel, return_exceptions=True)
      logger.info('Running pending tasks till complete')
      # TODO: obtain all the results, and log any results that are exceptions
      # other than CancelledError. Will be useful for troubleshooting.
      loop.run_until_complete(group)
  
      logger.info('Waiting for executor shutdown.')
      executor.shutdown(wait=True)
      # If loop was supplied, it's up to the caller to close!
      if not loop_was_supplied:
          logger.info('Closing the loop.')
          loop.close()
      logger.critical('Leaving. Bye!')