class_docstr: Kill Workers Randomly
  
  This kills workers in a cluster randomly.  It is intended to be used in
  stress testing.
  
  Parameters
  ----------
  delay: str
      The expected amount of time for a worker to live.
      The actual time will vary, treating worker death as a poisson process.
  mode: str
      or "graceful" which calls worker.close(...)
      Either "sys.exit" which calls sys.exit(0)
      or "segfault" which triggers a segfault
code: def __init__(
      self,
      delay: str | int | float = "100 s",
      mode: Literal["sys.exit", "graceful", "segfault"] = "sys.exit",
  ):
      self.delay = parse_timedelta(delay)
      if mode not in ("sys.exit", "graceful", "segfault"):
          raise ValueError(
              f"Three modes supported, 'sys.exit', 'graceful', and 'segfault'. "
              f"got {mode!r}"
          )
      self.mode = mode
  
file_path: distributed/distributed/chaos.py
imports: from __future__ import annotations
  import asyncio
  import ctypes
  import random
  import sys
  from typing import Literal
  from dask.utils import parse_timedelta
  from distributed.diagnostics.plugin import WorkerPlugin
label_desc: Use image node_id 1 to create a new KillWorker object from inherited base classes: WorkerPlugin with example: obj = KillWorker(delay, mode)