class_docstr: A Process that pulls replays and processes them.
code: def run(self):
      signal.signal(
          signal.SIGTERM, lambda a, b: sys.exit()
      )  # Exit quietly.
      self._update_stage("spawn")
      replay_name = "none"
      while True:
          self._print("Starting up a new SC2 instance.")
          self._update_stage("launch")
          try:
              with self.run_config.start(
                  want_rgb=interface.HasField("render")
              ) as controller:
                  self._print("SC2 Started successfully.")
                  ping = controller.ping()
                  for _ in range(300):
                      try:
                          replay_path = self.replay_queue.get()
                      except queue.Empty:
                          self._update_stage("done")
                          self._print("Empty queue, returning")
                          return
                      try:
                          replay_name = os.path.basename(replay_path)[
                              :10
                          ]
                          self.stats.replay = replay_name
                          self._print("Got replay: %s" % replay_path)
                          self._update_stage("open replay file")
                          replay_data = self.run_config.replay_data(
                              replay_path
                          )
                          self._update_stage("replay_info")
                          info = controller.replay_info(replay_data)
                          self._print(
                              (" Replay Info %s " % replay_name).center(
                                  60, "-"
                              )
                          )
                          self._print(info)
                          self._print("-" * 60)
                          if valid_replay(info, ping):
                              self.stats.replay_stats.maps[
                                  info.map_name
                              ] += 1
                              for player_info in info.player_info:
                                  race_name = sc_common.Race.Name(
                                      player_info.player_info.race_actual
                                  )
                                  self.stats.replay_stats.races[
                                      race_name
                                  ] += 1
                              map_data = None
                              if info.local_map_path:
                                  self._update_stage("open map file")
                                  map_data = self.run_config.map_data(
                                      info.local_map_path
                                  )
                              for player_id in [1, 2]:
                                  self._print(
                                      "Starting %s from player %s's perspective"
                                      % (replay_name, player_id)
                                  )
                                  self.process_replay(
                                      controller,
                                      replay_data,
                                      map_data,
                                      player_id,
                                  )
                          else:
                              self._print("Replay is invalid.")
                              self.stats.replay_stats.invalid_replays.add(
                                  replay_name
                              )
                      finally:
                          self.replay_queue.task_done()
                  self._update_stage("shutdown")
          except (
              protocol.ConnectionError,
              protocol.ProtocolError,
              remote_controller.RequestError,
          ):
              self.stats.replay_stats.crashing_replays.add(replay_name)
          except KeyboardInterrupt:
              return
  
imports: import collections
  import multiprocessing
  import os
  import queue
  import signal
  import sys
  import threading
  import time
  from absl import app
  from absl import flags
  from pysc2 import run_configs
  from pysc2.lib import features
  from pysc2.lib import point
  from pysc2.lib import protocol
  from pysc2.lib import remote_controller
  from pysc2.lib import replay
  from pysc2.lib import static_data
  from pysc2.lib import gfile
  from s2clientprotocol import common_pb2
  from s2clientprotocol import sc2api_pb2
label_desc: Use image node_id 2 for calling the ReplayProcessor obj's underlying member method code with example usage: obj.run() without return types