code: def _keep_alive(self, get_work_response):
          
          if not self._config.keep_alive:
              return False
          elif self._assistant:
              return True
          elif self._config.count_last_scheduled:
              return get_work_response.n_pending_last_scheduled > 0
          elif self._config.count_uniques:
              return get_work_response.n_unique_pending > 0
          elif get_work_response.n_pending_tasks == 0:
              return False
          elif not self._config.max_keep_alive_idle_duration:
              return True
          elif not self._idle_since:
              return True
          else:
              time_to_shutdown = self._idle_since + self._config.max_keep_alive_idle_duration - datetime.datetime.now()
              logger.debug("[%s] %s until shutdown", self._id, time_to_shutdown)
              return time_to_shutdown > datetime.timedelta(0)
docs: Returns true if a worker should stay alive given.
  
          If worker-keep-alive is not set, this will always return false.
          For an assistant, it will always return the value of worker-keep-alive.
          Otherwise, it will return true for nonzero n_pending_tasks.
  
          If worker-count-uniques is true, it will also
          require that one of the tasks is unique to this worker.