code: def _enable_thread_pool(func):
      
  
      @functools.wraps(func)
      def wrapper(*args, **kwargs):
          self = args[0]
          if self.enable_thread_pool and hasattr(self, 'thread_pool'):
              future = self.thread_pool.submit(func, *args, **kwargs)
              is_async = kwargs.get('is_async')
              if is_async is None or not is_async:
                  timeout = kwargs.get('timeout')
                  if timeout is None:
                      timeout = 2
                  try:
                      result = future.result(timeout=timeout)
                  except TimeoutError as e:
                      self.logger.exception(e)
                      result = None
                  return result
              return future
          else:
              return func(*args, **kwargs)
  
      return wrapper
docs: Use thread pool for executing a task if self.enable_thread_pool is True.
  
      Return an instance of future when flag is_async is True otherwise will to
      block waiting for the result until timeout then returns the result.