code: def run_in_executor(f):
      
  
      @wraps(f)
      def new_f(self, *args, **kwargs):
  
          if self.is_shutdown:
              return
          try:
              future = self.executor.submit(f, self, *args, **kwargs)
              future.add_done_callback(_future_completed)
          except Exception:
              log.exception("Failed to submit task to executor")
  
      return new_f
docs: A decorator to run the given method in the ThreadPoolExecutor.