class_docstr: PIDServer tracks PIDs reported by a set of pid_clients which connect to it.
  
  PIDServer.run() will return when all pid_clients have reported a graceful shutdown and have
  exited, or it will raise an exception if any pids disappear without reporting a graceful
  shutdown.
  
  PIDServer lets an sshd-based launch layer keep track of its worker processes, even when the
  worker processes aren't proper child processes.
class_docstr_tok: ["PIDServer","tracks","PIDs","reported","by","a","set","of","pid_clients","which","connect","to","it",".","PIDServer.run","(",")","will","return","when","all","pid_clients","have","reported","a","graceful","shutdown","and","have","exited",",","or","it","will","raise","an","exception","if","any","pids","disappear","without","reporting","a","graceful","shutdown",".","PIDServer","lets","an","sshd-based","launch","layer","keep","track","of","its","worker","processes",",","even","when","the","worker","processes","are","n't","proper","child","processes","."]
code: def run(
      self,
      health_check: Optional[Callable] = None,
      poll_period: float = 1,
  ) -> None:
      assert self.sel, "must start first"
      # Continue waiting until all workers have connected and subsequently exited gracefully.
      while (
          self.listener
          or len(self.graceful_shutdowns) < self.num_clients
      ):
          # Get some read events.
          for key, mask in self.sel.select(timeout=poll_period):
              if key.fileobj == self.listener:
                  self.handle_listener(mask)
              elif key.fileobj in self.conns:
                  conn = key.fileobj
                  assert isinstance(conn, socket.socket)
                  self.handle_conn(conn, mask)
              else:
                  raise AssertionError(
                      f"unexpected key from select(): {key}"
                  )
  
          self.check_pids()
  
          # Otherwise, run the externally-provided health check.
          if health_check is not None:
              health_check()
  
imports: import logging
  import os
  import selectors
  import signal
  import socket
  import subprocess
  import time
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import determined
label_desc: Use image node_id 9 for calling the PIDServer obj's underlying member method code with example usage: obj.run(health_check, poll_period) without return types