class_docstr: Process that terminates an experiment when `max_steps` is reached.
class_docstr_tok: ["Process","that","terminates","an","experiment","when","`","max_steps","`","is","reached","."]
docstr: Run steps limiter to terminate an experiment when max_steps is reached.
      
docstr_tok: ["Run","steps","limiter","to","terminate","an","experiment","when","max_steps","is","reached","."]
code: def run(self):
      """Run steps limiter to terminate an experiment when max_steps is reached."""
  
      logging.info(
          "StepsLimiter: Starting with max_steps = %d (%s)",
          self._max_steps,
          self._steps_key,
      )
      with signals.runtime_terminator():
          while True:
              # Update the counts.
              counts = self._counter.get_counts()
              num_steps = counts.get(self._steps_key, 0)
  
              logging.info(
                  "StepsLimiter: Reached %d recorded steps", num_steps
              )
  
              if num_steps > self._max_steps:
                  logging.info(
                      "StepsLimiter: Max steps of %d was reached, terminating",
                      self._max_steps,
                  )
                  # Avoid importing Launchpad until it is actually used.
                  import launchpad as lp  # pylint: disable=g-import-not-at-top
  
                  lp.stop()
  
              # Don't spam the counter.
              for _ in range(10):
                  # Do not sleep for a long period of time to avoid LaunchPad program
                  # termination hangs (time.sleep is not interruptible).
                  time.sleep(1)
  
file_path: acme/acme/utils/lp_utils.py
imports: import atexit
  import functools
  import inspect
  import os
  import sys
  import time
  from typing import Any, Callable, Optional
  from absl import flags
  from absl import logging
  from acme.utils import counting
  from acme.utils import signals
label_desc: Use image node_id 2 for calling the StepsLimiter obj's underlying member method code with example usage: obj.run() without return types